Browse Source

Changed: treeModel.Range minor optimization.

Szymon Cofalik 10 years ago
parent
commit
484c423ca4
1 changed files with 3 additions and 1 deletions
  1. 3 1
      packages/ckeditor5-engine/src/treemodel/range.js

+ 3 - 1
packages/ckeditor5-engine/src/treemodel/range.js

@@ -228,10 +228,11 @@ export default class Range {
 		let diffAt = ( typeof cmp == 'string' ) ? Math.min( this.start.path.length, this.end.path.length ) : cmp;
 
 		let pos = Position.createFromPosition( this.start );
+		let posParent = pos.parent;
 
 		// Go up.
 		while ( pos.path.length > diffAt + 1 ) {
-			let howMany = pos.parent.getChildCount() - pos.offset;
+			let howMany = posParent.getChildCount() - pos.offset;
 
 			if ( howMany !== 0 ) {
 				ranges.push( new Range( pos, pos.getShiftedBy( howMany ) ) );
@@ -239,6 +240,7 @@ export default class Range {
 
 			pos.path = pos.path.slice( 0, -1 );
 			pos.offset++;
+			posParent = posParent.parent;
 		}
 
 		// Go down.