8
0
Просмотр исходного кода

Changed: Position.getAncestors() was returning nodes in different order than Node.getAncestors().

Szymon Cofalik 9 лет назад
Родитель
Сommit
3dc1540fd2

+ 1 - 1
packages/ckeditor5-engine/src/model/position.js

@@ -265,7 +265,7 @@ export default class Position {
 		if ( this.parent instanceof DocumentFragment ) {
 			return [ this.parent ];
 		} else {
-			return this.parent.getAncestors( { includeNode: true, parentFirst: true } );
+			return this.parent.getAncestors( { includeNode: true } );
 		}
 	}
 

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

@@ -148,7 +148,7 @@ export default class Position {
 		if ( this.parent instanceof DocumentFragment ) {
 			return [ this.parent ];
 		} else {
-			return this.parent.getAncestors( { includeNode: true, parentFirst: true } );
+			return this.parent.getAncestors( { includeNode: true } );
 		}
 	}
 
@@ -208,8 +208,8 @@ export default class Position {
 		}
 
 		// Get path from root to position's parent element.
-		const path = this.getAncestors().reverse();
-		const otherPath = otherPosition.getAncestors().reverse();
+		const path = this.getAncestors();
+		const otherPath = otherPosition.getAncestors();
 
 		// Compare both path arrays to find common ancestor.
 		const result = compareArrays( path, otherPath );

+ 1 - 1
packages/ckeditor5-engine/tests/model/position.js

@@ -503,7 +503,7 @@ describe( 'position', () => {
 
 	describe( 'getAncestors', () => {
 		it( 'should return position parent element and it\'s ancestors', () => {
-			expect( new Position( root, [ 1, 1, 1 ] ).getAncestors() ).to.deep.equal( [ li2, ul, root ] );
+			expect( new Position( root, [ 1, 1, 1 ] ).getAncestors() ).to.deep.equal( [ root, ul, li2 ] );
 		} );
 
 		it( 'should return DocumentFragment if position is directly in document fragment', () => {

+ 1 - 1
packages/ckeditor5-engine/tests/view/position.js

@@ -121,7 +121,7 @@ describe( 'Position', () => {
 			const div = new Element( 'div', null, p );
 			const docFrag = new DocumentFragment( div );
 
-			expect( new Position( foo, 1 ).getAncestors() ).to.deep.equal( [ foo, p, div, docFrag ] );
+			expect( new Position( foo, 1 ).getAncestors() ).to.deep.equal( [ docFrag, div, p, foo ] );
 		} );
 
 		it( 'should return DocumentFragment if position is directly in document fragment', () => {