Forráskód Böngészése

Changed: Slight refactor in `view.Position#compareWith`.

Szymon Cofalik 7 éve
szülő
commit
3fc9fbb618
1 módosított fájl, 3 hozzáadás és 7 törlés
  1. 3 7
      packages/ckeditor5-engine/src/view/position.js

+ 3 - 7
packages/ckeditor5-engine/src/view/position.js

@@ -251,13 +251,9 @@ export default class Position {
 			return 'same';
 		}
 
-		// Get path from root to position's parent element. "Indexify" the paths (change elements to indices).
-		const thisPath = this.getAncestors().map( element => element.index );
-		const otherPath = otherPosition.getAncestors().map( element => element.index );
-
-		// Remove `null`s that came from root elements.
-		thisPath.shift();
-		otherPath.shift();
+		// Get path from root to position's parent element.
+		const thisPath = this.parent.is( 'node' ) ? this.parent.getPath() : [];
+		const otherPath = otherPosition.parent.is( 'node' ) ? otherPosition.parent.getPath() : [];
 
 		// Add the positions' offsets to the parents offsets.
 		thisPath.push( this.offset );