Răsfoiți Sursa

Changed AttributeOperation to copy passed range in constructor.

Szymon Cofalik 10 ani în urmă
părinte
comite
b21a8d7568

+ 2 - 2
packages/ckeditor5-engine/src/treemodel/operation/attributeoperation.js

@@ -42,7 +42,7 @@ CKEDITOR.define( [
 			 * @readonly
 			 * @type {treeModel.Range}
 			 */
-			this.range = range;
+			this.range = range.clone();
 
 			/**
 			 * Old attribute to change. Set to `null` if operation inserts a new attribute.
@@ -66,7 +66,7 @@ CKEDITOR.define( [
 		}
 
 		clone() {
-			return new AttributeOperation( this.range.clone(), this.oldAttr, this.newAttr, this.baseVersion );
+			return new AttributeOperation( this.range, this.oldAttr, this.newAttr, this.baseVersion );
 		}
 
 		getReversed() {

+ 1 - 1
packages/ckeditor5-engine/tests/treemodel/operation/attributeoperation.js

@@ -184,7 +184,7 @@ describe( 'AttributeOperation', () => {
 
 		expect( reverse ).to.be.an.instanceof( AttributeOperation );
 		expect( reverse.baseVersion ).to.equal( 1 );
-		expect( reverse.range ).to.equal( range );
+		expect( reverse.range.isEqual( range ) ).to.be.true;
 		expect( reverse.oldAttr ).to.equal( newAttr );
 		expect( reverse.newAttr ).to.equal( oldAttr );
 	} );