瀏覽代碼

Fixed: Wrong usage of `is()` method.

Szymon Cofalik 8 年之前
父節點
當前提交
2926e2a20e

+ 1 - 1
packages/ckeditor5-engine/src/view/attributeelement.js

@@ -110,7 +110,7 @@ function getFillerOffset() {
 	let element = this.parent;
 
 	// <p><b></b></p> needs filler -> <p><b><br></b></p>
-	while ( element.is( 'attributeElement' ) ) {
+	while ( element && element.is( 'attributeElement' ) ) {
 		if ( element.childCount > 1 ) {
 			return null;
 		}

+ 6 - 0
packages/ckeditor5-engine/tests/view/attributeelement.js

@@ -131,5 +131,11 @@ describe( 'AttributeElement', () => {
 
 			expect( attribute.getFillerOffset() ).to.be.null;
 		} );
+
+		it( 'should return null if there is no parent', () => {
+			const attribute = new AttributeElement( 'b' );
+
+			expect( attribute.getFillerOffset() ).to.be.null;
+		} );
 	} );
 } );