Explorar o código

Merge pull request #836 from ckeditor/t/835

Internal: Improved element check in `AttributeElement#getFillerOffset()` because it is expected that `element` may be `null`. Closes #835.
Piotrek Koszuliński %!s(int64=8) %!d(string=hai) anos
pai
achega
4539f932f4

+ 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;
+		} );
 	} );
 } );