From a163b72376b0ed62207167926090a699f7eb4a1e Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Wed, 21 Mar 2018 14:00:48 +0100 Subject: [PATCH] Changed: Slight refactor in `view.Position#compareWith`. --- src/view/position.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/view/position.js b/src/view/position.js index dfc9b856d..1ccdd16db 100644 --- a/src/view/position.js +++ b/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 );