Przeglądaj źródła

Renamed and changed order of arguments in engine.model.Batch setAttr and removeAttr methods.

Szymon Kupś 9 lat temu
rodzic
commit
64332fe20d

+ 10 - 10
packages/ckeditor5-engine/src/model/delta/attributedelta.js

@@ -14,8 +14,8 @@ import RootElement from '../rootelement.js';
 import Element from '../element.js';
 
 /**
- * To provide specific OT behavior and better collisions solving, change methods ({@link engine.model.Batch#setAttr}
- * and {@link engine.model.Batch#removeAttr}) use `AttributeDelta` class which inherits from the `Delta` class and may
+ * To provide specific OT behavior and better collisions solving, change methods ({@link engine.model.Batch#setAttribute}
+ * and {@link engine.model.Batch#removeAttribute}) use `AttributeDelta` class which inherits from the `Delta` class and may
  * overwrite some methods.
  *
  * @memberOf engine.model.delta
@@ -81,8 +81,8 @@ export default class AttributeDelta extends Delta {
 }
 
 /**
- * To provide specific OT behavior and better collisions solving, change methods ({@link engine.model.Batch#setAttr}
- * and {@link engine.model.Batch#removeAttr}) use `RootAttributeDelta` class which inherits from the `Delta` class and may
+ * To provide specific OT behavior and better collisions solving, change methods ({@link engine.model.Batch#setAttribute}
+ * and {@link engine.model.Batch#removeAttribute}) use `RootAttributeDelta` class which inherits from the `Delta` class and may
  * overwrite some methods.
  *
  * @memberOf engine.model.delta
@@ -101,12 +101,12 @@ export class RootAttributeDelta extends Delta {
  * Sets the value of the attribute of the node or on the range.
  *
  * @chainable
- * @method engine.model.Batch#setAttr
+ * @method engine.model.Batch#setAttribute
+ * @param {engine.model.Node|engine.model.Range} nodeOrRange Node or range on which the attribute will be set.
  * @param {String} key Attribute key.
  * @param {*} value Attribute new value.
- * @param {engine.model.Node|engine.model.Range} nodeOrRange Node or range on which the attribute will be set.
  */
-register( 'setAttr', function( key, value, nodeOrRange ) {
+register( 'setAttribute', function( nodeOrRange, key, value ) {
 	attribute( this, key, value, nodeOrRange );
 
 	return this;
@@ -116,11 +116,11 @@ register( 'setAttr', function( key, value, nodeOrRange ) {
  * Removes an attribute from the range.
  *
  * @chainable
- * @method engine.model.Batch#removeAttr
- * @param {String} key Attribute key.
  * @param {engine.model.Node|engine.model.Range} nodeOrRange Node or range on which the attribute will be removed.
+ * @method engine.model.Batch#removeAttribute
+ * @param {String} key Attribute key.
  */
-register( 'removeAttr', function( key, nodeOrRange ) {
+register( 'removeAttribute', function( nodeOrRange, key ) {
 	attribute( this, key, null, nodeOrRange );
 
 	return this;

+ 4 - 4
packages/ckeditor5-engine/src/model/liveselection.js

@@ -220,7 +220,7 @@ export default class LiveSelection extends Selection {
 			const storeKey = LiveSelection._getStoreAttributeKey( key );
 
 			this._document.enqueueChanges( () => {
-				this._document.batch().removeAttr( storeKey, selectionParent );
+				this._document.batch().removeAttribute( selectionParent, storeKey );
 			} );
 		}
 	}
@@ -240,7 +240,7 @@ export default class LiveSelection extends Selection {
 			const storeKey = LiveSelection._getStoreAttributeKey( key );
 
 			this._document.enqueueChanges( () => {
-				this._document.batch().setAttr( storeKey, value, selectionParent );
+				this._document.batch().setAttribute( selectionParent, storeKey, value );
 			} );
 		}
 	}
@@ -261,13 +261,13 @@ export default class LiveSelection extends Selection {
 				for ( let attr of this._getStoredAttributes() ) {
 					const storeKey = LiveSelection._getStoreAttributeKey( attr[ 0 ] );
 
-					batch.removeAttr( storeKey, selectionParent );
+					batch.removeAttribute( selectionParent, storeKey );
 				}
 
 				for ( let attr of attrs ) {
 					const storeKey = LiveSelection._getStoreAttributeKey( attr[ 0 ] );
 
-					batch.setAttr( storeKey, attr[ 1 ], selectionParent );
+					batch.setAttribute( selectionParent, storeKey, attr[ 1 ] );
 				}
 			} );
 		}

+ 13 - 13
packages/ckeditor5-engine/tests/conversion/modelconversiondispatcher.js

@@ -118,13 +118,13 @@ describe( 'ModelConversionDispatcher', () => {
 			dispatcher.on( 'addAttribute:key:$text', cbAddText );
 			dispatcher.on( 'addAttribute:key:image', cbAddImage );
 
-			doc.batch().setAttr( 'key', 'value', image );
+			doc.batch().setAttribute( image, 'key', 'value' );
 
 			// Callback for adding attribute on text not called.
 			expect( cbAddText.called ).to.be.false;
 			expect( cbAddImage.calledOnce ).to.be.true;
 
-			doc.batch().setAttr( 'key', 'value', ModelRange.createFromParentsAndOffsets( root, 3, root, 4 ) );
+			doc.batch().setAttribute( ModelRange.createFromParentsAndOffsets( root, 3, root, 4 ), 'key', 'value' );
 
 			expect( cbAddText.calledOnce ).to.be.true;
 			// Callback for adding attribute on image not called this time.
@@ -138,14 +138,14 @@ describe( 'ModelConversionDispatcher', () => {
 			dispatcher.on( 'changeAttribute:key:$text', cbChangeText );
 			dispatcher.on( 'changeAttribute:key:image', cbChangeImage );
 
-			doc.batch().setAttr( 'key', 'value', image ).setAttr( 'key', 'newValue', image );
+			doc.batch().setAttribute( image, 'key', 'value' ).setAttribute( image, 'key', 'newValue' );
 
 			// Callback for adding attribute on text not called.
 			expect( cbChangeText.called ).to.be.false;
 			expect( cbChangeImage.calledOnce ).to.be.true;
 
 			const range = ModelRange.createFromParentsAndOffsets( root, 3, root, 4 );
-			doc.batch().setAttr( 'key', 'value', range ).setAttr( 'key', 'newValue', range );
+			doc.batch().setAttribute( range, 'key', 'value' ).setAttribute( range, 'key', 'newValue' );
 
 			expect( cbChangeText.calledOnce ).to.be.true;
 			// Callback for adding attribute on image not called this time.
@@ -159,14 +159,14 @@ describe( 'ModelConversionDispatcher', () => {
 			dispatcher.on( 'removeAttribute:key:$text', cbRemoveText );
 			dispatcher.on( 'removeAttribute:key:image', cbRemoveImage );
 
-			doc.batch().setAttr( 'key', 'value', image ).removeAttr( 'key', image );
+			doc.batch().setAttribute( image, 'key', 'value' ).removeAttribute( image, 'key' );
 
 			// Callback for adding attribute on text not called.
 			expect( cbRemoveText.called ).to.be.false;
 			expect( cbRemoveImage.calledOnce ).to.be.true;
 
 			const range = ModelRange.createFromParentsAndOffsets( root, 3, root, 4 );
-			doc.batch().setAttr( 'key', 'value', range ).removeAttr( 'key', range );
+			doc.batch().setAttribute( range, 'key', 'value' ).removeAttribute( range, 'key' );
 
 			expect( cbRemoveText.calledOnce ).to.be.true;
 			// Callback for adding attribute on image not called this time.
@@ -187,7 +187,7 @@ describe( 'ModelConversionDispatcher', () => {
 			let gyNode = new ModelElement( 'image' );
 			doc.graveyard.appendChildren( gyNode );
 
-			doc.batch().setAttr( 'key', 'value', gyNode );
+			doc.batch().setAttribute( gyNode, 'key', 'value' );
 
 			expect( dispatcher.fire.called ).to.be.false;
 		} );
@@ -389,8 +389,8 @@ describe( 'ModelConversionDispatcher', () => {
 		it( 'should prepare correct list of consumable values', () => {
 			doc.enqueueChanges( () => {
 				doc.batch()
-					.setAttr( 'bold', true, ModelRange.createFromElement( root ) )
-					.setAttr( 'italic', true, ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ) );
+					.setAttribute( ModelRange.createFromElement( root ), 'bold', true )
+					.setAttribute( ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ), 'italic', true );
 			} );
 
 			dispatcher.on( 'selection', ( evt, data, consumable ) => {
@@ -407,8 +407,8 @@ describe( 'ModelConversionDispatcher', () => {
 
 			doc.enqueueChanges( () => {
 				doc.batch()
-					.setAttr( 'bold', true, ModelRange.createFromElement( root ) )
-					.setAttr( 'italic', true, ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ) );
+					.setAttribute( ModelRange.createFromElement( root ), 'bold', true )
+					.setAttribute( ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ), 'italic', true );
 			} );
 
 			dispatcher.convertSelection( doc.selection );
@@ -426,8 +426,8 @@ describe( 'ModelConversionDispatcher', () => {
 
 			doc.enqueueChanges( () => {
 				doc.batch()
-					.setAttr( 'bold', true, ModelRange.createFromElement( root ) )
-					.setAttr( 'italic', true, ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ) );
+					.setAttribute( ModelRange.createFromElement( root ), 'bold', true )
+					.setAttribute( ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ), 'italic', true );
 			} );
 
 			dispatcher.convertSelection( doc.selection );

+ 2 - 2
packages/ckeditor5-engine/tests/model/batch.js

@@ -18,8 +18,8 @@ describe( 'Batch', () => {
 	it( 'should have registered basic methods', () => {
 		const batch = new Batch( new Document() );
 
-		expect( batch.setAttr ).to.be.a( 'function' );
-		expect( batch.removeAttr ).to.be.a( 'function' );
+		expect( batch.setAttribute ).to.be.a( 'function' );
+		expect( batch.removeAttribute ).to.be.a( 'function' );
 	} );
 
 	describe( 'type', () => {

+ 50 - 50
packages/ckeditor5-engine/tests/model/delta/attributedelta.js

@@ -56,76 +56,76 @@ describe( 'Batch', () => {
 			char = root.getChild( 1 );
 		} );
 
-		describe( 'setAttr', () => {
+		describe( 'setAttribute', () => {
 			it( 'should create the attribute on element', () => {
-				batch.setAttr( 'b', 2, node );
+				batch.setAttribute( node, 'b', 2 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( node.getAttribute( 'b' ) ).to.equal( 2 );
 			} );
 
 			it( 'should change the attribute of element', () => {
-				batch.setAttr( 'a', 2, node );
+				batch.setAttribute( node, 'a', 2 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( node.getAttribute( 'a' ) ).to.equal( 2 );
 			} );
 
 			it( 'should create the attribute on text node', () => {
-				batch.setAttr( 'b', 2, char );
+				batch.setAttribute( char, 'b', 2 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( root.getChild( 1 ).getAttribute( 'b' ) ).to.equal( 2 );
 			} );
 
 			it( 'should change the attribute of text node', () => {
-				batch.setAttr( 'a', 2, char );
+				batch.setAttribute( char, 'a', 2 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( root.getChild( 1 ).getAttribute( 'a' ) ).to.equal( 2 );
 			} );
 
 			it( 'should do nothing if the attribute value is the same', () => {
-				batch.setAttr( 'a', 1, node );
+				batch.setAttribute( node, 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 0 );
 				expect( node.getAttribute( 'a' ) ).to.equal( 1 );
 			} );
 
 			it( 'should be chainable', () => {
-				const chain = batch.setAttr( 'b', 2, node );
+				const chain = batch.setAttribute( node, 'b', 2 );
 				expect( chain ).to.equal( batch );
 			} );
 
 			it( 'should add delta to batch and operation to delta before applying operation', () => {
 				sinon.spy( doc, 'applyOperation' );
-				batch.setAttr( 'b', 2, node );
+				batch.setAttribute( node, 'b', 2 );
 
 				expect( doc.applyOperation.calledWith( correctDeltaMatcher ) ).to.be.true;
 			} );
 		} );
 
-		describe( 'removeAttr', () => {
+		describe( 'removeAttribute', () => {
 			it( 'should remove the attribute from element', () => {
-				batch.removeAttr( 'a', node );
+				batch.removeAttribute( node, 'a' );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( node.getAttribute( 'a' ) ).to.be.undefined;
 			} );
 
 			it( 'should remove the attribute from character', () => {
-				batch.removeAttr( 'a', char );
+				batch.removeAttribute( char, 'a' );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( root.getChild( 1 ).getAttribute( 'a' ) ).to.be.undefined;
 			} );
 
 			it( 'should do nothing if the attribute is not set', () => {
-				batch.removeAttr( 'b', node );
+				batch.removeAttribute( node, 'b' );
 				expect( getOperationsCount() ).to.equal( 0 );
 			} );
 
 			it( 'should be chainable', () => {
-				const chain = batch.removeAttr( 'a', node );
+				const chain = batch.removeAttribute( node, 'a' );
 				expect( chain ).to.equal( batch );
 			} );
 
 			it( 'should add delta to batch and operation to delta before applying operation', () => {
 				sinon.spy( doc, 'applyOperation' );
-				batch.removeAttr( 'a', node );
+				batch.removeAttribute( node, 'a' );
 
 				expect( doc.applyOperation.calledWith( correctDeltaMatcher ) ).to.be.true;
 			} );
@@ -174,44 +174,44 @@ describe( 'Batch', () => {
 				.join( '' );
 		}
 
-		describe( 'setAttr', () => {
+		describe( 'setAttribute', () => {
 			it( 'should set the attribute on the range', () => {
-				batch.setAttr( 'a', 3, getRange( 3, 6 ) );
+				batch.setAttribute( getRange( 3, 6 ), 'a', 3 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( getChangesAttrsCount() ).to.equal( 3 );
 				expect( getCompressedAttrs() ).to.equal( '111333111222---1112------' );
 			} );
 
 			it( 'should split the operations if parts of the range have different attributes', () => {
-				batch.setAttr( 'a', 3, getRange( 4, 14 ) );
+				batch.setAttribute( getRange( 4, 14 ), 'a', 3 );
 				expect( getOperationsCount() ).to.equal( 4 );
 				expect( getChangesAttrsCount() ).to.equal( 10 );
 				expect( getCompressedAttrs() ).to.equal( '111-3333333333-1112------' );
 			} );
 
 			it( 'should split the operations if parts of the part of the range have the attribute', () => {
-				batch.setAttr( 'a', 2, getRange( 4, 14 ) );
+				batch.setAttribute( getRange( 4, 14 ), 'a', 2 );
 				expect( getOperationsCount() ).to.equal( 3 );
 				expect( getChangesAttrsCount() ).to.equal( 7 );
 				expect( getCompressedAttrs() ).to.equal( '111-2222222222-1112------' );
 			} );
 
 			it( 'should strip the range if the beginning have the attribute', () => {
-				batch.setAttr( 'a', 1, getRange( 1, 5 ) );
+				batch.setAttribute( getRange( 1, 5 ), 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( getChangesAttrsCount() ).to.equal( 2 );
 				expect( getCompressedAttrs() ).to.equal( '11111-111222---1112------' );
 			} );
 
 			it( 'should strip the range if the ending have the attribute', () => {
-				batch.setAttr( 'a', 1, getRange( 13, 17 ) );
+				batch.setAttribute( getRange( 13, 17 ), 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( getChangesAttrsCount() ).to.equal( 2 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222-111112------' );
 			} );
 
 			it( 'should do nothing if the range has attribute', () => {
-				batch.setAttr( 'a', 1, getRange( 0, 3 ) );
+				batch.setAttribute( getRange( 0, 3 ), 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 0 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 			} );
@@ -222,7 +222,7 @@ describe( 'Batch', () => {
 					new Position( root, [ 19 ] )
 				);
 
-				batch.setAttr( 'a', 1, range );
+				batch.setAttribute( range, 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( getChangesAttrsCount() ).to.equal( 2 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---1112-11---' );
@@ -234,7 +234,7 @@ describe( 'Batch', () => {
 					new Position( root, [ 21 ] )
 				);
 
-				batch.setAttr( 'a', 1, range );
+				batch.setAttribute( range, 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( getChangesAttrsCount() ).to.equal( 4 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---1112-1111-' );
@@ -246,75 +246,75 @@ describe( 'Batch', () => {
 					new Position( root, [ 19 ] )
 				);
 
-				batch.setAttr( 'a', 3, range );
+				batch.setAttribute( range, 'a', 3 );
 				expect( getOperationsCount() ).to.equal( 0 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 			} );
 
 			it( 'should not create an operation if is collapsed', () => {
-				batch.setAttr( 'a', 1, getRange( 3, 3 ) );
+				batch.setAttribute( getRange( 3, 3 ), 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 0 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 			} );
 
 			it( 'should create a proper operations for the mixed range', () => {
-				batch.setAttr( 'a', 1, getRange( 0, 20 ) );
+				batch.setAttribute( getRange( 0, 20 ), 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 5 );
 				expect( getChangesAttrsCount() ).to.equal( 14 );
 				expect( getCompressedAttrs() ).to.equal( '11111111111111111111111--' );
 			} );
 
 			it( 'should be chainable', () => {
-				const chain = batch.setAttr( 'a', 3, getRange( 3, 6 ) );
+				const chain = batch.setAttribute( getRange( 3, 6 ), 'a', 3 );
 				expect( chain ).to.equal( batch );
 			} );
 
 			it( 'should add delta to batch and operation to delta before applying operation', () => {
 				sinon.spy( doc, 'applyOperation' );
-				batch.setAttr( 'a', 3, getRange( 3, 6 ) );
+				batch.setAttribute( getRange( 3, 6 ), 'a', 3 );
 
 				expect( doc.applyOperation.calledWith( correctDeltaMatcher ) ).to.be.true;
 			} );
 		} );
 
-		describe( 'removeAttr', () => {
+		describe( 'removeAttribute', () => {
 			it( 'should remove the attribute on the range', () => {
-				batch.removeAttr( 'a', getRange( 0, 2 ) );
+				batch.removeAttribute( getRange( 0, 2 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( getChangesAttrsCount() ).to.equal( 2 );
 				expect( getCompressedAttrs() ).to.equal( '--1---111222---1112------' );
 			} );
 
 			it( 'should split the operations if parts of the range have different attributes', () => {
-				batch.removeAttr( 'a', getRange( 7, 11 ) );
+				batch.removeAttribute( getRange( 7, 11 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 2 );
 				expect( getChangesAttrsCount() ).to.equal( 4 );
 				expect( getCompressedAttrs() ).to.equal( '111---1----2---1112------' );
 			} );
 
 			it( 'should split the operations if parts of the part of the range have no attribute', () => {
-				batch.removeAttr( 'a', getRange( 1, 7 ) );
+				batch.removeAttribute( getRange( 1, 7 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 2 );
 				expect( getChangesAttrsCount() ).to.equal( 3 );
 				expect( getCompressedAttrs() ).to.equal( '1------11222---1112------' );
 			} );
 
 			it( 'should strip the range if the beginning have no attribute', () => {
-				batch.removeAttr( 'a', getRange( 4, 12 ) );
+				batch.removeAttribute( getRange( 4, 12 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 2 );
 				expect( getChangesAttrsCount() ).to.equal( 6 );
 				expect( getCompressedAttrs() ).to.equal( '111------------1112------' );
 			} );
 
 			it( 'should strip the range if the ending have no attribute', () => {
-				batch.removeAttr( 'a', getRange( 7, 15 ) );
+				batch.removeAttribute( getRange( 7, 15 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 2 );
 				expect( getChangesAttrsCount() ).to.equal( 5 );
 				expect( getCompressedAttrs() ).to.equal( '111---1--------1112------' );
 			} );
 
 			it( 'should do nothing if the range has no attribute', () => {
-				batch.removeAttr( 'a', getRange( 4, 5 ) );
+				batch.removeAttribute( getRange( 4, 5 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 0 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 			} );
@@ -325,40 +325,40 @@ describe( 'Batch', () => {
 					new Position( root, [ 19 ] )
 				);
 
-				batch.removeAttr( 'a', range );
+				batch.removeAttribute( range, 'a' );
 				expect( getOperationsCount() ).to.equal( 0 );
 				expect( getChangesAttrsCount() ).to.equal( 0 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 			} );
 
 			it( 'should not apply operation twice in the range contains opening and closing tags', () => {
-				batch.removeAttr( 'a', getRange( 18, 22 ) );
+				batch.removeAttribute( getRange( 18, 22 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( getChangesAttrsCount() ).to.equal( 1 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---111-------' );
 			} );
 
 			it( 'should not create an operation if range is collapsed', () => {
-				batch.removeAttr( 'a', getRange( 3, 3 ) );
+				batch.removeAttribute( getRange( 3, 3 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 0 );
 				expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 			} );
 
 			it( 'should create a proper operations for the mixed range', () => {
-				batch.removeAttr( 'a', getRange( 3, 15 ) );
+				batch.removeAttribute( getRange( 3, 15 ), 'a' );
 				expect( getOperationsCount() ).to.equal( 2 );
 				expect( getChangesAttrsCount() ).to.equal( 6 );
 				expect( getCompressedAttrs() ).to.equal( '111------------1112------' );
 			} );
 
 			it( 'should be chainable', () => {
-				const chain = batch.removeAttr( 'a', getRange( 0, 2 ) );
+				const chain = batch.removeAttribute( getRange( 0, 2 ), 'a' );
 				expect( chain ).to.equal( batch );
 			} );
 
 			it( 'should add delta to batch and operation to delta before applying operation', () => {
 				sinon.spy( doc, 'applyOperation' );
-				batch.removeAttr( 'a', getRange( 0, 2 ) );
+				batch.removeAttribute( getRange( 0, 2 ), 'a' );
 
 				expect( doc.applyOperation.calledWith( correctDeltaMatcher ) ).to.be.true;
 			} );
@@ -366,38 +366,38 @@ describe( 'Batch', () => {
 	} );
 
 	describe( 'change attribute on root element', () => {
-		describe( 'setAttr', () => {
+		describe( 'setAttribute', () => {
 			it( 'should create the attribute on root', () => {
-				batch.setAttr( 'b', 2, root );
+				batch.setAttribute( root, 'b', 2  );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( root.getAttribute( 'b' ) ).to.equal( 2 );
 			} );
 
 			it( 'should change the attribute of root', () => {
-				batch.setAttr( 'a', 2, root );
+				batch.setAttribute( root, 'a', 2 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( root.getAttribute( 'a' ) ).to.equal( 2 );
 			} );
 
 			it( 'should do nothing if the attribute value is the same', () => {
-				batch.setAttr( 'a', 1, root );
+				batch.setAttribute( root, 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 1 );
-				batch.setAttr( 'a', 1, root );
+				batch.setAttribute( root, 'a', 1 );
 				expect( getOperationsCount() ).to.equal( 1 );
 				expect( root.getAttribute( 'a' ) ).to.equal( 1 );
 			} );
 		} );
 
-		describe( 'removeAttr', () => {
+		describe( 'removeAttribute', () => {
 			it( 'should remove the attribute from root', () => {
-				batch.setAttr( 'a', 1, root );
-				batch.removeAttr( 'a', root );
+				batch.setAttribute( root, 'a', 1 );
+				batch.removeAttribute( root, 'a' );
 				expect( getOperationsCount() ).to.equal( 2 );
 				expect( root.getAttribute( 'a' ) ).to.be.undefined;
 			} );
 
 			it( 'should do nothing if the attribute is not set', () => {
-				batch.removeAttr( 'b', root );
+				batch.removeAttribute( root, 'b' );
 				expect( getOperationsCount() ).to.equal( 0 );
 			} );
 		} );

+ 1 - 1
packages/ckeditor5-engine/tests/tickets/475/475.js

@@ -73,7 +73,7 @@ export default class AutoLinker extends Feature {
 
 				doc.enqueueChanges( () => {
 					const urlRange = Range.createFromPositionAndShift( livePos, url.length );
-					batch.setAttr( 'link', url, urlRange );
+					batch.setAttribute( urlRange, 'link', url );
 				} );
 			}
 		} );

+ 2 - 2
packages/ckeditor5-engine/tests/view/node.js

@@ -247,7 +247,7 @@ describe( 'Node', () => {
 			sinon.assert.calledWith( rootChangeSpy, 'attributes', img );
 		} );
 
-		describe( 'setAttr', () => {
+		describe( 'setAttribute', () => {
 			it( 'should fire change event', () => {
 				img.setAttribute( 'width', 100 );
 
@@ -256,7 +256,7 @@ describe( 'Node', () => {
 			} );
 		} );
 
-		describe( 'removeAttr', () => {
+		describe( 'removeAttribute', () => {
 			it( 'should fire change event', () => {
 				img.removeAttribute( 'src' );