Browse Source

Filter out disallowed attributes from title-content element.

Oskar Wróbel 6 years ago
parent
commit
aed496095d

+ 1 - 1
packages/ckeditor5-heading/src/title.js

@@ -238,7 +238,7 @@ export default class Title extends Plugin {
 					writer.rename( rootChild, 'title-content' );
 
 					// After changing element to the title it has to be filtered out from disallowed attributes.
-					model.schema.removeDisallowedAttributes( Array.from( rootChild.getChildren() ), writer );
+					model.schema.removeDisallowedAttributes( [ rootChild ], writer );
 
 				// If the first element cannot be a title but title is already in the root
 				// than move the first element after a title.

+ 6 - 5
packages/ckeditor5-heading/tests/title.js

@@ -186,16 +186,17 @@ describe( 'Title', () => {
 		} );
 
 		it( 'should clear element from attributes when changing to title element', () => {
-			model.schema.extend( '$text', { allowAttributes: 'bold' } );
+			model.schema.extend( '$text', { allowAttributes: 'foo' } );
+			model.schema.extend( 'paragraph', { allowAttributes: [ 'foo', 'alignment' ] } );
 
 			setData( model,
-				'<paragraph>F<$text bold="true">o</$text>o</paragraph>' +
-				'<paragraph>B<$text bold="true">a</$text>r</paragraph>'
+				'<paragraph alignment="justify" foo="true">F<$text foo="true">o</$text>o</paragraph>' +
+				'<paragraph foo="true">B<$text foo="true">a</$text>r</paragraph>'
 			);
 
 			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]Foo</title-content></title>' +
-				'<paragraph>B<$text bold="true">a</$text>r</paragraph>'
+				'<title><title-content alignment="justify">[]Foo</title-content></title>' +
+				'<paragraph foo="true">B<$text foo="true">a</$text>r</paragraph>'
 			);
 		} );