소스 검색

Changed: treeModel.Range minor optimization.

Szymon Cofalik 10 년 전
부모
커밋
484c423ca4
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  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 diffAt = ( typeof cmp == 'string' ) ? Math.min( this.start.path.length, this.end.path.length ) : cmp;
 
 
 		let pos = Position.createFromPosition( this.start );
 		let pos = Position.createFromPosition( this.start );
+		let posParent = pos.parent;
 
 
 		// Go up.
 		// Go up.
 		while ( pos.path.length > diffAt + 1 ) {
 		while ( pos.path.length > diffAt + 1 ) {
-			let howMany = pos.parent.getChildCount() - pos.offset;
+			let howMany = posParent.getChildCount() - pos.offset;
 
 
 			if ( howMany !== 0 ) {
 			if ( howMany !== 0 ) {
 				ranges.push( new Range( pos, pos.getShiftedBy( howMany ) ) );
 				ranges.push( new Range( pos, pos.getShiftedBy( howMany ) ) );
@@ -239,6 +240,7 @@ export default class Range {
 
 
 			pos.path = pos.path.slice( 0, -1 );
 			pos.path = pos.path.slice( 0, -1 );
 			pos.offset++;
 			pos.offset++;
+			posParent = posParent.parent;
 		}
 		}
 
 
 		// Go down.
 		// Go down.