8
0
فهرست منبع

Reverted part of "Renamed method `detach` to `destroy` in multiple classes."

This reverts commit 514f50add0f80171cb9c93d9645698bebd3ecfb7.
Piotrek Koszuliński 9 سال پیش
والد
کامیت
a08ddfea03

+ 2 - 2
packages/ckeditor5-engine/src/treemodel/liveposition.js

@@ -13,7 +13,7 @@ import utils from '../../utils/utils.js';
 /**
  * LivePosition is a position in the Tree Model that updates itself as the tree changes. It may be used as a bookmark.
  * **Note:** Be very careful when dealing with LivePosition. Each LivePosition instance bind events that might
- * have to be unbound. Use {@link core.treeModel.LivePosition#destroy} whenever you don't need LivePosition anymore.
+ * have to be unbound. Use {@link core.treeModel.LivePosition#detach} whenever you don't need LivePosition anymore.
  *
  * @memberOf core.treeModel
  * @extends core.treeModel.Position
@@ -60,7 +60,7 @@ export default class LivePosition extends Position {
 	 * anymore (i.e. when leaving scope in which it was declared or before re-assigning variable that was
 	 * referring to it).
 	 */
-	destroy() {
+	detach() {
 		this.stopListening();
 	}
 

+ 4 - 4
packages/ckeditor5-engine/src/treemodel/liverange.js

@@ -16,7 +16,7 @@ import utils from '../../utils/utils.js';
  * **Note:** Constructor creates it's own {@link core.treeModel.LivePosition} instances basing on passed values.
  *
  * **Note:** Be very careful when dealing with LiveRange. Each LiveRange instance bind events that might
- * have to be unbound. Use {@link core.treeModel.LiveRange#destroy destroy} whenever you don't need LiveRange anymore.
+ * have to be unbound. Use {@link core.treeModel.LiveRange#detach detach} whenever you don't need LiveRange anymore.
  *
  * @memberOf core.treeModel
  */
@@ -40,9 +40,9 @@ export default class LiveRange extends Range {
 	 * anymore (i.e. when leaving scope in which it was declared or before re-assigning variable that was
 	 * referring to it).
 	 */
-	destroy() {
-		this.start.destroy();
-		this.end.destroy();
+	detach() {
+		this.start.detach();
+		this.end.detach();
 		this.stopListening();
 	}
 

+ 1 - 1
packages/ckeditor5-engine/src/treemodel/selection.js

@@ -132,7 +132,7 @@ export default class Selection {
 	 */
 	destroy() {
 		for ( let i = 0; i < this._ranges.length; i++ ) {
-			this._ranges[ i ].destroy();
+			this._ranges[ i ].detach();
 		}
 	}
 

+ 12 - 12
packages/ckeditor5-engine/tests/treemodel/liveposition.js

@@ -30,7 +30,7 @@ describe( 'LivePosition', () => {
 
 	it( 'should be an instance of Position', () => {
 		let live = new LivePosition( root, [ 0 ] );
-		live.destroy();
+		live.detach();
 
 		expect( live ).to.be.instanceof( Position );
 	} );
@@ -39,18 +39,18 @@ describe( 'LivePosition', () => {
 		sinon.spy( LivePosition.prototype, 'listenTo' );
 
 		let live = new LivePosition( root, [ 0 ] );
-		live.destroy();
+		live.detach();
 
 		expect( live.listenTo.calledWith( doc, 'change' ) ).to.be.true;
 
 		LivePosition.prototype.listenTo.restore();
 	} );
 
-	it( 'should stop listening when destroyed', () => {
+	it( 'should stop listening when detached', () => {
 		sinon.spy( LivePosition.prototype, 'stopListening' );
 
 		let live = new LivePosition( root, [ 0 ] );
-		live.destroy();
+		live.detach();
 
 		expect( live.stopListening.called ).to.be.true;
 
@@ -60,25 +60,25 @@ describe( 'LivePosition', () => {
 	it( 'createFromPosition should return LivePosition', () => {
 		let position = LivePosition.createFromPosition( new Position( root, [ 0 ] ) );
 		expect( position ).to.be.instanceof( LivePosition );
-		position.destroy();
+		position.detach();
 	} );
 
 	it( 'createFromParentAndOffset should return LivePosition', () => {
 		let position = LivePosition.createFromParentAndOffset( ul, 0 );
 		expect( position ).to.be.instanceof( LivePosition );
-		position.destroy();
+		position.detach();
 	} );
 
 	it( 'createBefore should return LivePosition', () => {
 		let position = LivePosition.createBefore( ul );
 		expect( position ).to.be.instanceof( LivePosition );
-		position.destroy();
+		position.detach();
 	} );
 
 	it( 'createAfter should return LivePosition', () => {
 		let position = LivePosition.createAfter( ul );
 		expect( position ).to.be.instanceof( LivePosition );
-		position.destroy();
+		position.detach();
 	} );
 
 	describe( 'should get transformed if', () => {
@@ -89,7 +89,7 @@ describe( 'LivePosition', () => {
 		} );
 
 		afterEach( () => {
-			live.destroy();
+			live.detach();
 		} );
 
 		describe( 'insertion', () => {
@@ -227,7 +227,7 @@ describe( 'LivePosition', () => {
 		} );
 
 		afterEach( () => {
-			live.destroy();
+			live.detach();
 		} );
 
 		describe( 'insertion', () => {
@@ -247,7 +247,7 @@ describe( 'LivePosition', () => {
 
 				expect( live.path ).to.deep.equal( path );
 
-				live.destroy();
+				live.detach();
 			} );
 
 			it( 'is after a node from the position path', () => {
@@ -294,7 +294,7 @@ describe( 'LivePosition', () => {
 
 				expect( live.path ).to.deep.equal( path );
 
-				live.destroy();
+				live.detach();
 			} );
 
 			it( 'is at a position after a node from the live position path', () => {

+ 10 - 10
packages/ckeditor5-engine/tests/treemodel/liverange.js

@@ -39,7 +39,7 @@ describe( 'LiveRange', () => {
 
 	it( 'should be an instance of Range', () => {
 		let live = new LiveRange( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
-		live.destroy();
+		live.detach();
 
 		expect( live ).to.be.instanceof( Range );
 	} );
@@ -48,18 +48,18 @@ describe( 'LiveRange', () => {
 		sinon.spy( LiveRange.prototype, 'listenTo' );
 
 		let live = new LiveRange( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
-		live.destroy();
+		live.detach();
 
 		expect( live.listenTo.calledWith( doc, 'change' ) ).to.be.true;
 
 		LiveRange.prototype.listenTo.restore();
 	} );
 
-	it( 'should stop listening when destroyed', () => {
+	it( 'should stop listening when detached', () => {
 		sinon.spy( LiveRange.prototype, 'stopListening' );
 
 		let live = new LiveRange( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
-		live.destroy();
+		live.detach();
 
 		expect( live.stopListening.called ).to.be.true;
 
@@ -69,25 +69,25 @@ describe( 'LiveRange', () => {
 	it( 'createFromElement should return LiveRange', () => {
 		let range = LiveRange.createFromElement( p );
 		expect( range ).to.be.instanceof( LiveRange );
-		range.destroy();
+		range.detach();
 	} );
 
 	it( 'createFromParentsAndOffsets should return LiveRange', () => {
 		let range = LiveRange.createFromParentsAndOffsets( root, 0, p, 2 );
 		expect( range ).to.be.instanceof( LiveRange );
-		range.destroy();
+		range.detach();
 	} );
 
 	it( 'createFromPositionAndShift should return LiveRange', () => {
 		let range = LiveRange.createFromPositionAndShift( new Position( root, [ 0, 1 ] ), 4 );
 		expect( range ).to.be.instanceof( LiveRange );
-		range.destroy();
+		range.detach();
 	} );
 
 	it( 'createFromRange should return LiveRange', () => {
 		let range = LiveRange.createFromRange( new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ) );
 		expect( range ).to.be.instanceof( LiveRange );
-		range.destroy();
+		range.detach();
 	} );
 
 	// Examples may seem weird when you compare them with the tree structure generated at the beginning of tests.
@@ -102,7 +102,7 @@ describe( 'LiveRange', () => {
 		} );
 
 		afterEach( () => {
-			live.destroy();
+			live.detach();
 		} );
 
 		describe( 'insertion', () => {
@@ -349,7 +349,7 @@ describe( 'LiveRange', () => {
 		} );
 
 		afterEach( () => {
-			live.destroy();
+			live.detach();
 		} );
 
 		describe( 'insertion', () => {

+ 21 - 21
packages/ckeditor5-engine/tests/treemodel/selection.js

@@ -47,7 +47,7 @@ describe( 'Selection', () => {
 
 	afterEach( () => {
 		doc.destroy();
-		liveRange.destroy();
+		liveRange.detach();
 	} );
 
 	it( 'should be set to default range when just created', () => {
@@ -149,16 +149,16 @@ describe( 'Selection', () => {
 
 		let ranges = selection.getRanges();
 
-		sinon.spy( ranges[ 0 ], 'destroy' );
-		sinon.spy( ranges[ 1 ], 'destroy' );
+		sinon.spy( ranges[ 0 ], 'detach' );
+		sinon.spy( ranges[ 1 ], 'detach' );
 
 		selection.destroy();
 
-		expect( ranges[ 0 ].destroy.called ).to.be.true;
-		expect( ranges[ 1 ].destroy.called ).to.be.true;
+		expect( ranges[ 0 ].detach.called ).to.be.true;
+		expect( ranges[ 1 ].detach.called ).to.be.true;
 
-		ranges[ 0 ].destroy.restore();
-		ranges[ 1 ].destroy.restore();
+		ranges[ 0 ].detach.restore();
+		ranges[ 1 ].detach.restore();
 	} );
 
 	it( 'should throw an error if added range intersects with already stored range', () => {
@@ -186,15 +186,15 @@ describe( 'Selection', () => {
 
 			ranges = selection.getRanges();
 
-			sinon.spy( ranges[ 0 ], 'destroy' );
-			sinon.spy( ranges[ 1 ], 'destroy' );
+			sinon.spy( ranges[ 0 ], 'detach' );
+			sinon.spy( ranges[ 1 ], 'detach' );
 
 			selection.removeAllRanges();
 		} );
 
 		afterEach( () => {
-			ranges[ 0 ].destroy.restore();
-			ranges[ 1 ].destroy.restore();
+			ranges[ 0 ].detach.restore();
+			ranges[ 1 ].detach.restore();
 		} );
 
 		it( 'should remove all stored ranges (and reset to default range)', () => {
@@ -207,9 +207,9 @@ describe( 'Selection', () => {
 			expect( spy.calledOnce ).to.be.true;
 		} );
 
-		it( 'should destroy removed ranges', () => {
-			expect( ranges[ 0 ].destroy.called ).to.be.true;
-			expect( ranges[ 1 ].destroy.called ).to.be.true;
+		it( 'should detach ranges', () => {
+			expect( ranges[ 0 ].detach.called ).to.be.true;
+			expect( ranges[ 1 ].detach.called ).to.be.true;
 		} );
 	} );
 
@@ -232,13 +232,13 @@ describe( 'Selection', () => {
 
 			oldRanges = selection.getRanges();
 
-			sinon.spy( oldRanges[ 0 ], 'destroy' );
-			sinon.spy( oldRanges[ 1 ], 'destroy' );
+			sinon.spy( oldRanges[ 0 ], 'detach' );
+			sinon.spy( oldRanges[ 1 ], 'detach' );
 		} );
 
 		afterEach( () => {
-			oldRanges[ 0 ].destroy.restore();
-			oldRanges[ 1 ].destroy.restore();
+			oldRanges[ 0 ].detach.restore();
+			oldRanges[ 1 ].detach.restore();
 		} );
 
 		it( 'should remove all ranges and add given ranges', () => {
@@ -268,10 +268,10 @@ describe( 'Selection', () => {
 			expect( spy.calledOnce ).to.be.true;
 		} );
 
-		it( 'should destroy removed LiveRanges', () => {
+		it( 'should detach removed LiveRanges', () => {
 			selection.setRanges( newRanges );
-			expect( oldRanges[ 0 ].destroy.called ).to.be.true;
-			expect( oldRanges[ 1 ].destroy.called ).to.be.true;
+			expect( oldRanges[ 0 ].detach.called ).to.be.true;
+			expect( oldRanges[ 1 ].detach.called ).to.be.true;
 		} );
 	} );