8
0
Просмотр исходного кода

Merging nodes can create really nasty situations.

Piotrek Koszuliński 6 лет назад
Родитель
Сommit
3573f60e7d
1 измененных файлов с 29 добавлено и 0 удалено
  1. 29 0
      packages/ckeditor5-engine/tests/model/schema.js

+ 29 - 0
packages/ckeditor5-engine/tests/model/schema.js

@@ -1850,6 +1850,35 @@ describe( 'Schema', () => {
 				expect( getData( model, { withoutSelection: true } ) ).to.equal( '<div>abc</div>' );
 			} );
 		} );
+
+		it( 'should filter out all attributes from descendants that are merged while clearing', () => {
+			schema.addAttributeCheck( ( ctx, attributeName ) => {
+				// Disallow `a` in div>$text.
+				if ( ctx.endsWith( 'div $text' ) && ( attributeName == 'a' || attributeName == 'b' ) ) {
+					return false;
+				}
+			} );
+
+			const a = new Text( 'a', { a: 1, b: 1 } );
+			const b = new Text( 'b', { b: 1 } );
+			const c = new Text( 'c', { a: 1, b: 1 } );
+			const div = new Element( 'div', [], [ a, b, c ] );
+
+			root._appendChild( [ div ] );
+
+			model.change( writer => {
+				schema.removeDisallowedAttributes( [ div ], writer );
+
+				expect( writer.batch.operations ).to.length( 5 );
+				expect( writer.batch.operations[ 0 ] ).to.instanceof( AttributeOperation );
+				expect( writer.batch.operations[ 1 ] ).to.instanceof( AttributeOperation );
+				expect( writer.batch.operations[ 2 ] ).to.instanceof( AttributeOperation );
+				expect( writer.batch.operations[ 3 ] ).to.instanceof( AttributeOperation );
+				expect( writer.batch.operations[ 4 ] ).to.instanceof( AttributeOperation );
+
+				expect( getData( model, { withoutSelection: true } ) ).to.equal( '<div>abc</div>' );
+			} );
+		} );
 	} );
 
 	describe( 'definitions compilation', () => {