Browse Source

Cache parent here too.

Piotrek Koszuliński 5 years ago
parent
commit
f3e446119e
1 changed files with 5 additions and 3 deletions
  1. 5 3
      packages/ckeditor5-engine/src/model/position.js

+ 5 - 3
packages/ckeditor5-engine/src/model/position.js

@@ -346,10 +346,12 @@ export default class Position {
 	 * @returns {Array.<module:engine/model/item~Item>} Array with ancestors.
 	 */
 	getAncestors() {
-		if ( this.parent.is( 'documentFragment' ) ) {
-			return [ this.parent ];
+		const parent = this.parent;
+
+		if ( parent.is( 'documentFragment' ) ) {
+			return [ parent ];
 		} else {
-			return this.parent.getAncestors( { includeSelf: true } );
+			return parent.getAncestors( { includeSelf: true } );
 		}
 	}