|
|
@@ -460,6 +460,49 @@ describe( 'downcast-helpers', () => {
|
|
|
|
|
|
expectResult( '<img class="styled-pull-out"></img>' );
|
|
|
} );
|
|
|
+
|
|
|
+ // #1587
|
|
|
+ it( 'config.view and config.model as strings in generic conversion (elements only)', () => {
|
|
|
+ conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
|
|
|
+
|
|
|
+ conversion.for( 'downcast' ).add( downcastAttributeToAttribute( { model: 'test', view: 'test' } ) );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.insertElement( 'paragraph', { test: '1' }, modelRoot, 0 );
|
|
|
+ writer.insertElement( 'paragraph', { test: '2' }, modelRoot, 1 );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expectResult( '<p test="1"></p><p test="2"></p>' );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.removeAttribute( 'test', modelRoot.getChild( 1 ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expectResult( '<p test="1"></p><p></p>' );
|
|
|
+ } );
|
|
|
+
|
|
|
+ // #1587
|
|
|
+ it( 'config.view and config.model as strings in generic conversion (elements + text)', () => {
|
|
|
+ conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
|
|
|
+
|
|
|
+ conversion.for( 'downcast' ).add( downcastAttributeToAttribute( { model: 'test', view: 'test' } ) );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.insertElement( 'paragraph', modelRoot, 0 );
|
|
|
+ writer.insertElement( 'paragraph', { test: '1' }, modelRoot, 1 );
|
|
|
+
|
|
|
+ writer.insertText( 'Foo', { test: '2' }, modelRoot.getChild( 0 ), 0 );
|
|
|
+ writer.insertText( 'Bar', { test: '3' }, modelRoot.getChild( 1 ), 0 );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expectResult( '<p>Foo</p><p test="1">Bar</p>' );
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.removeAttribute( 'test', modelRoot.getChild( 1 ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ expectResult( '<p>Foo</p><p>Bar</p>' );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'downcastMarkerToElement', () => {
|