8
0
Pārlūkot izejas kodu

Changed params order in Batch#setAttributes.

Oskar Wróbel 8 gadi atpakaļ
vecāks
revīzija
6c4c9538ad

+ 1 - 1
packages/ckeditor5-engine/src/conversion/buildviewconverter.js

@@ -528,7 +528,7 @@ function setAttributeOn( toChange, attribute, data, conversionApi ) {
 	};
 
 	if ( conversionApi.schema.check( schemaQuery ) ) {
-		data.batch.setAttribute( toChange, attribute.key, attribute.value );
+		data.batch.setAttribute( attribute.key, attribute.value, toChange );
 	}
 }
 

+ 25 - 28
packages/ckeditor5-engine/src/model/batch.js

@@ -327,7 +327,7 @@ export default class Batch {
 	 *		batch.appendText( 'foo', paragraph );
 	 *		batch.appendText( 'foo', { 'bold': true }, paragraph );
 	 *
-	 * @param {String} data Text data.
+	 * @param {String} text Text data.
 	 * @param {Object} [attributes] Text attributes.
 	 * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} parent
 	 */
@@ -349,11 +349,11 @@ export default class Batch {
 	 * @param {Object} [attributes] Elements attributes.
 	 * @param {module:engine/model/element~Element|module:engine/model/documentfragment~DocumentFragment} parent
 	 */
-	appendElement( text, attributes, parent ) {
+	appendElement( name, attributes, parent ) {
 		if ( attributes instanceof DocumentFragment || attributes instanceof Element ) {
-			this.insert( this.createElement( text ), attributes, 'end' );
+			this.insert( this.createElement( name ), attributes, 'end' );
 		} else {
-			this.insert( this.createElement( text, attributes ), parent, 'end' );
+			this.insert( this.createElement( name, attributes ), parent, 'end' );
 		}
 	}
 
@@ -361,12 +361,12 @@ export default class Batch {
 	 * Sets value of the attribute with given key on a {@link module:engine/model/item~Item model item}
 	 * or on a {@link module:engine/model/range~Range range}.
 	 *
-	 * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange
-	 * Model item or range on which the attribute will be set.
 	 * @param {String} key Attribute key.
 	 * @param {*} value Attribute new value.
+	 * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange
+	 * Model item or range on which the attribute will be set.
 	 */
-	setAttribute( itemOrRange, key, value ) {
+	setAttribute( key, value, itemOrRange ) {
 		if ( itemOrRange instanceof Range ) {
 			setAttributeToRange( this, key, value, itemOrRange );
 		} else {
@@ -378,18 +378,18 @@ export default class Batch {
 	 * Sets values of attributes on a {@link module:engine/model/item~Item model item}
 	 * or on a {@link module:engine/model/range~Range range}.
 	 *
-	 *		batch.setAttributes( range, {
+	 *		batch.setAttributes( {
 	 *			'bold': true,
 	 *			'italic': true
-	 *		} );
+	 *		}, range );
 	 *
+	 * @param {Object} attributes Attributes keys and values.
 	 * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange
 	 * Model item or range on which the attributes will be set.
-	 * @param {Object} attributes Attributes keys and values.
 	 */
-	setAttributes( itemOrRange, attributes ) {
+	setAttributes( attributes, itemOrRange ) {
 		for ( const [ key, val ] of toMap( attributes ) ) {
-			this.setAttribute( itemOrRange, key, val );
+			this.setAttribute( key, val, itemOrRange );
 		}
 	}
 
@@ -397,12 +397,11 @@ export default class Batch {
 	 * Removes an attribute with given key from a {@link module:engine/model/item~Item model item}
 	 * or from a {@link module:engine/model/range~Range range}.
 	 *
+	 * @param {String} key Attribute key.
 	 * @param {module:engine/model/item~Item|module:engine/model/range~Range} itemOrRange
 	 * Model item or range from which the attribute will be removed.
-	 * @method module:engine/model/batch~Batch#removeAttribute
-	 * @param {String} key Attribute key.
 	 */
-	removeAttribute( itemOrRange, key ) {
+	removeAttribute( key, itemOrRange ) {
 		if ( itemOrRange instanceof Range ) {
 			setAttributeToRange( this, key, null, itemOrRange );
 		} else {
@@ -419,7 +418,7 @@ export default class Batch {
 	clearAttributes( itemOrRange ) {
 		const removeAttributesFromItem = item => {
 			for ( const attribute of item.getAttributeKeys() ) {
-				this.removeAttribute( item, attribute );
+				this.removeAttribute( attribute, item );
 			}
 		};
 
@@ -819,18 +818,16 @@ export default class Batch {
 	}
 }
 
-/**
- * Sets given attribute to each node in given range. When attribute value is null then attribute will be removed.
- *
- * Because attribute operation needs to have the same attribute value on the whole range, this function splits
- * the range into smaller parts.
- *
- * @private
- * @param {module:engine/model/batch~Batch} batch
- * @param {String} key Attribute key.
- * @param {*} value Attribute new value.
- * @param {module:engine/model/range~Range} range Model range on which the attribute will be set.
- */
+// Sets given attribute to each node in given range. When attribute value is null then attribute will be removed.
+//
+// Because attribute operation needs to have the same attribute value on the whole range, this function splits
+// the range into smaller parts.
+//
+// @private
+// @param {module:engine/model/batch~Batch} batch
+// @param {String} key Attribute key.
+// @param {*} value Attribute new value.
+// @param {module:engine/model/range~Range} range Model range on which the attribute will be set.
 function setAttributeToRange( batch, key, value, range ) {
 	const delta = new AttributeDelta();
 	const doc = batch.document;

+ 5 - 5
packages/ckeditor5-engine/src/model/documentselection.js

@@ -543,7 +543,7 @@ export default class DocumentSelection extends Selection {
 	_removeStoredAttribute( key ) {
 		const storeKey = DocumentSelection._getStoreAttributeKey( key );
 
-		this._document.batch().removeAttribute( this.anchor.parent, storeKey );
+		this._document.batch().removeAttribute( storeKey, this.anchor.parent );
 	}
 
 	/**
@@ -556,7 +556,7 @@ export default class DocumentSelection extends Selection {
 	_storeAttribute( key, value ) {
 		const storeKey = DocumentSelection._getStoreAttributeKey( key );
 
-		this._document.batch().setAttribute( this.anchor.parent, storeKey, value );
+		this._document.batch().setAttribute( storeKey, value, this.anchor.parent );
 	}
 
 	/**
@@ -572,13 +572,13 @@ export default class DocumentSelection extends Selection {
 		for ( const [ oldKey ] of this._getStoredAttributes() ) {
 			const storeKey = DocumentSelection._getStoreAttributeKey( oldKey );
 
-			batch.removeAttribute( selectionParent, storeKey );
+			batch.removeAttribute( storeKey, selectionParent );
 		}
 
 		for ( const [ key, value ] of attrs ) {
 			const storeKey = DocumentSelection._getStoreAttributeKey( key );
 
-			batch.setAttribute( selectionParent, storeKey, value );
+			batch.setAttribute( storeKey, value, selectionParent );
 		}
 	}
 
@@ -731,7 +731,7 @@ function clearAttributesStoredInElement( changes, batch, document ) {
 		const storedAttributes = Array.from( changeParent.getAttributeKeys() ).filter( key => key.startsWith( storePrefix ) );
 
 		for ( const key of storedAttributes ) {
-			batch.removeAttribute( changeParent, key );
+			batch.removeAttribute( key, changeParent );
 		}
 	} );
 }

+ 1 - 1
packages/ckeditor5-engine/src/model/schema.js

@@ -432,7 +432,7 @@ export default class Schema {
 				// TODO: this should be improved to check all combination of attributes.
 				for ( const attribute of node.getAttributeKeys() ) {
 					if ( !this.check( { name, attributes: attribute, inside: queryPath } ) ) {
-						batch.removeAttribute( node, attribute );
+						batch.removeAttribute( attribute, node );
 					}
 				}
 			}

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

@@ -112,13 +112,13 @@ describe( 'ModelConversionDispatcher', () => {
 			dispatcher.on( 'addAttribute:key:$text', cbAddText );
 			dispatcher.on( 'addAttribute:key:image', cbAddImage );
 
-			doc.batch().setAttribute( image, 'key', 'value' );
+			doc.batch().setAttribute( 'key', 'value', image );
 
 			// Callback for adding attribute on text not called.
 			expect( cbAddText.called ).to.be.false;
 			expect( cbAddImage.calledOnce ).to.be.true;
 
-			doc.batch().setAttribute( ModelRange.createFromParentsAndOffsets( root, 3, root, 4 ), 'key', 'value' );
+			doc.batch().setAttribute( 'key', 'value', ModelRange.createFromParentsAndOffsets( root, 3, root, 4 ) );
 
 			expect( cbAddText.calledOnce ).to.be.true;
 			// Callback for adding attribute on image not called this time.
@@ -133,16 +133,16 @@ describe( 'ModelConversionDispatcher', () => {
 			dispatcher.on( 'changeAttribute:key:$text', cbChangeText );
 			dispatcher.on( 'changeAttribute:key:image', cbChangeImage );
 
-			batch.setAttribute( image, 'key', 'value' );
-			batch.setAttribute( image, 'key', 'newValue' );
+			batch.setAttribute( 'key', 'value', image );
+			batch.setAttribute( 'key', 'newValue', image );
 
 			// 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 );
-			batch.setAttribute( range, 'key', 'value' );
-			batch.setAttribute( range, 'key', 'newValue' );
+			batch.setAttribute( 'key', 'value', range );
+			batch.setAttribute( 'key', 'newValue', range );
 
 			expect( cbChangeText.calledOnce ).to.be.true;
 			// Callback for adding attribute on image not called this time.
@@ -157,16 +157,16 @@ describe( 'ModelConversionDispatcher', () => {
 			dispatcher.on( 'removeAttribute:key:$text', cbRemoveText );
 			dispatcher.on( 'removeAttribute:key:image', cbRemoveImage );
 
-			batch.setAttribute( image, 'key', 'value' );
-			batch.removeAttribute( image, 'key' );
+			batch.setAttribute( 'key', 'value', image );
+			batch.removeAttribute( 'key', image );
 
 			// 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 );
-			batch.setAttribute( range, 'key', 'value' );
-			batch.removeAttribute( range, 'key' );
+			batch.setAttribute( 'key', 'value', range );
+			batch.removeAttribute( 'key', range );
 
 			expect( cbRemoveText.calledOnce ).to.be.true;
 			// Callback for adding attribute on image not called this time.
@@ -187,7 +187,7 @@ describe( 'ModelConversionDispatcher', () => {
 			const gyNode = new ModelElement( 'image' );
 			doc.graveyard.appendChildren( gyNode );
 
-			doc.batch().setAttribute( gyNode, 'key', 'value' );
+			doc.batch().setAttribute( 'key', 'value', gyNode );
 
 			expect( dispatcher.fire.called ).to.be.false;
 		} );
@@ -623,8 +623,8 @@ describe( 'ModelConversionDispatcher', () => {
 			doc.enqueueChanges( () => {
 				const batch = doc.batch();
 
-				batch.setAttribute( ModelRange.createIn( root ), 'bold', true );
-				batch.setAttribute( ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ), 'italic', true );
+				batch.setAttribute( 'bold', true, ModelRange.createIn( root ) );
+				batch.setAttribute( 'italic', true, ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ) );
 			} );
 
 			dispatcher.on( 'selection', ( evt, data, consumable ) => {
@@ -642,8 +642,8 @@ describe( 'ModelConversionDispatcher', () => {
 			doc.enqueueChanges( () => {
 				const batch = doc.batch();
 
-				batch.setAttribute( ModelRange.createIn( root ), 'bold', true );
-				batch.setAttribute( ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ), 'italic', true );
+				batch.setAttribute( 'bold', true, ModelRange.createIn( root ) );
+				batch.setAttribute( 'italic', true, ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ) );
 			} );
 
 			dispatcher.convertSelection( doc.selection, [] );
@@ -662,8 +662,8 @@ describe( 'ModelConversionDispatcher', () => {
 			doc.enqueueChanges( () => {
 				const batch = doc.batch();
 
-				batch.setAttribute( ModelRange.createIn( root ), 'bold', true );
-				batch.setAttribute( ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ), 'italic', true );
+				batch.setAttribute( 'bold', true, ModelRange.createIn( root ) );
+				batch.setAttribute( 'italic', true, ModelRange.createFromParentsAndOffsets( root, 4, root, 5 ) );
 			} );
 
 			dispatcher.convertSelection( doc.selection, [] );

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

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

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

@@ -955,31 +955,31 @@ describe( 'Batch', () => {
 
 			describe( 'setAttribute', () => {
 				it( 'should create the attribute on element', () => {
-					batch.setAttribute( node, 'b', 2 );
+					batch.setAttribute( 'b', 2, node );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( node.getAttribute( 'b' ) ).to.equal( 2 );
 				} );
 
 				it( 'should change the attribute of element', () => {
-					batch.setAttribute( node, 'a', 2 );
+					batch.setAttribute( 'a', 2, node );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( node.getAttribute( 'a' ) ).to.equal( 2 );
 				} );
 
 				it( 'should create the attribute on text node', () => {
-					batch.setAttribute( text, 'b', 2 );
+					batch.setAttribute( 'b', 2, text );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( root.getChild( 1 ).getAttribute( 'b' ) ).to.equal( 2 );
 				} );
 
 				it( 'should change the attribute of text node', () => {
-					batch.setAttribute( text, 'a', 2 );
+					batch.setAttribute( 'a', 2, text );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( root.getChild( 1 ).getAttribute( 'a' ) ).to.equal( 2 );
 				} );
 
 				it( 'should do nothing if the attribute value is the same', () => {
-					batch.setAttribute( node, 'a', 1 );
+					batch.setAttribute( 'a', 1, node );
 					expect( spy.callCount ).to.equal( 0 );
 					expect( node.getAttribute( 'a' ) ).to.equal( 1 );
 				} );
@@ -987,19 +987,19 @@ describe( 'Batch', () => {
 
 			describe( 'removeAttribute', () => {
 				it( 'should remove the attribute from element', () => {
-					batch.removeAttribute( node, 'a' );
+					batch.removeAttribute( 'a', node );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( node.getAttribute( 'a' ) ).to.be.undefined;
 				} );
 
 				it( 'should remove the attribute from character', () => {
-					batch.removeAttribute( text, 'a' );
+					batch.removeAttribute( 'a', text );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( root.getChild( 1 ).getAttribute( 'a' ) ).to.be.undefined;
 				} );
 
 				it( 'should do nothing if the attribute is not set', () => {
-					batch.removeAttribute( node, 'b' );
+					batch.removeAttribute( 'b', node );
 					expect( spy.callCount ).to.equal( 0 );
 				} );
 			} );
@@ -1054,42 +1054,42 @@ describe( 'Batch', () => {
 
 			describe( 'setAttribute', () => {
 				it( 'should set the attribute on the range', () => {
-					batch.setAttribute( getRange( 3, 6 ), 'a', 3 );
+					batch.setAttribute( 'a', 3, getRange( 3, 6 ) );
 					expect( spy.callCount ).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.setAttribute( getRange( 4, 14 ), 'a', 3 );
+					batch.setAttribute( 'a', 3, getRange( 4, 14 ) );
 					expect( spy.callCount ).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.setAttribute( getRange( 4, 14 ), 'a', 2 );
+					batch.setAttribute( 'a', 2, getRange( 4, 14 ) );
 					expect( spy.callCount ).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.setAttribute( getRange( 1, 5 ), 'a', 1 );
+					batch.setAttribute( 'a', 1, getRange( 1, 5 ) );
 					expect( spy.callCount ).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.setAttribute( getRange( 13, 17 ), 'a', 1 );
+					batch.setAttribute( 'a', 1, getRange( 13, 17 ) );
 					expect( spy.callCount ).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.setAttribute( getRange( 0, 3 ), 'a', 1 );
+					batch.setAttribute( 'a', 1, getRange( 0, 3 ) );
 					expect( spy.callCount ).to.equal( 0 );
 					expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 				} );
@@ -1100,7 +1100,7 @@ describe( 'Batch', () => {
 						new Position( root, [ 19 ] )
 					);
 
-					batch.setAttribute( range, 'a', 1 );
+					batch.setAttribute( 'a', 1, range );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( getChangesAttrsCount() ).to.equal( 2 );
 					expect( getCompressedAttrs() ).to.equal( '111---111222---1112-11---' );
@@ -1112,7 +1112,7 @@ describe( 'Batch', () => {
 						new Position( root, [ 21 ] )
 					);
 
-					batch.setAttribute( range, 'a', 1 );
+					batch.setAttribute( 'a', 1, range );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( getChangesAttrsCount() ).to.equal( 4 );
 					expect( getCompressedAttrs() ).to.equal( '111---111222---1112-1111-' );
@@ -1124,19 +1124,19 @@ describe( 'Batch', () => {
 						new Position( root, [ 19 ] )
 					);
 
-					batch.setAttribute( range, 'a', 3 );
+					batch.setAttribute( 'a', 3, range );
 					expect( spy.callCount ).to.equal( 0 );
 					expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 				} );
 
 				it( 'should not create an operation if is collapsed', () => {
-					batch.setAttribute( getRange( 3, 3 ), 'a', 1 );
+					batch.setAttribute( 'a', 1, getRange( 3, 3 ) );
 					expect( spy.callCount ).to.equal( 0 );
 					expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 				} );
 
 				it( 'should create a proper operations for the mixed range', () => {
-					batch.setAttribute( getRange( 0, 20 ), 'a', 1 );
+					batch.setAttribute( 'a', 1, getRange( 0, 20 ) );
 					expect( spy.callCount ).to.equal( 5 );
 					expect( getChangesAttrsCount() ).to.equal( 14 );
 					expect( getCompressedAttrs() ).to.equal( '11111111111111111111111--' );
@@ -1145,42 +1145,42 @@ describe( 'Batch', () => {
 
 			describe( 'removeAttribute', () => {
 				it( 'should remove the attribute on the range', () => {
-					batch.removeAttribute( getRange( 0, 2 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 0, 2 ) );
 					expect( spy.callCount ).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.removeAttribute( getRange( 7, 11 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 7, 11 ) );
 					expect( spy.callCount ).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.removeAttribute( getRange( 1, 7 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 1, 7 ) );
 					expect( spy.callCount ).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.removeAttribute( getRange( 4, 12 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 4, 12 ) );
 					expect( spy.callCount ).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.removeAttribute( getRange( 7, 15 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 7, 15 ) );
 					expect( spy.callCount ).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.removeAttribute( getRange( 4, 5 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 4, 5 ) );
 					expect( spy.callCount ).to.equal( 0 );
 					expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 				} );
@@ -1191,27 +1191,27 @@ describe( 'Batch', () => {
 						new Position( root, [ 19 ] )
 					);
 
-					batch.removeAttribute( range, 'a' );
+					batch.removeAttribute( 'a', range );
 					expect( spy.callCount ).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.removeAttribute( getRange( 18, 22 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 18, 22 ) );
 					expect( spy.callCount ).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.removeAttribute( getRange( 3, 3 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 3, 3 ) );
 					expect( spy.callCount ).to.equal( 0 );
 					expect( getCompressedAttrs() ).to.equal( '111---111222---1112------' );
 				} );
 
 				it( 'should create a proper operations for the mixed range', () => {
-					batch.removeAttribute( getRange( 3, 15 ), 'a' );
+					batch.removeAttribute( 'a', getRange( 3, 15 ) );
 					expect( spy.callCount ).to.equal( 2 );
 					expect( getChangesAttrsCount() ).to.equal( 6 );
 					expect( getCompressedAttrs() ).to.equal( '111------------1112------' );
@@ -1229,41 +1229,41 @@ describe( 'Batch', () => {
 
 			describe( 'setAttribute', () => {
 				it( 'should create the attribute on root', () => {
-					batch.setAttribute( root, 'b', 2 );
+					batch.setAttribute( 'b', 2, root );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( root.getAttribute( 'b' ) ).to.equal( 2 );
 				} );
 
 				it( 'should create the attribute on detached root', () => {
-					batch.setAttribute( p, 'b', 2 );
+					batch.setAttribute( 'b', 2, p );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( p.getAttribute( 'b' ) ).to.equal( 2 );
 				} );
 
 				it( 'should change the attribute of root', () => {
-					batch.setAttribute( root, 'a', 2 );
+					batch.setAttribute( 'a', 2, root );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( root.getAttribute( 'a' ) ).to.equal( 2 );
 				} );
 
 				it( 'should change the attribute of detached root', () => {
-					batch.setAttribute( p, 'a', 2 );
+					batch.setAttribute( 'a', 2, p );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( p.getAttribute( 'a' ) ).to.equal( 2 );
 				} );
 
 				it( 'should do nothing if the attribute value is the same', () => {
-					batch.setAttribute( root, 'a', 1 );
+					batch.setAttribute( 'a', 1, root );
 					expect( spy.callCount ).to.equal( 1 );
-					batch.setAttribute( root, 'a', 1 );
+					batch.setAttribute( 'a', 1, root );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( root.getAttribute( 'a' ) ).to.equal( 1 );
 				} );
 
 				it( 'should do nothing if the attribute value is the same on detached root', () => {
-					batch.setAttribute( p, 'a', 1 );
+					batch.setAttribute( 'a', 1, p );
 					expect( spy.callCount ).to.equal( 1 );
-					batch.setAttribute( p, 'a', 1 );
+					batch.setAttribute( 'a', 1, p );
 					expect( spy.callCount ).to.equal( 1 );
 					expect( p.getAttribute( 'a' ) ).to.equal( 1 );
 				} );
@@ -1271,15 +1271,15 @@ describe( 'Batch', () => {
 
 			describe( 'removeAttribute', () => {
 				it( 'should remove the attribute from root', () => {
-					batch.setAttribute( root, 'a', 1 );
-					batch.removeAttribute( root, 'a' );
+					batch.setAttribute( 'a', 1, root );
+					batch.removeAttribute( 'a', root );
 
 					expect( spy.callCount ).to.equal( 2 );
 					expect( root.getAttribute( 'a' ) ).to.be.undefined;
 				} );
 
 				it( 'should do nothing if the attribute is not set', () => {
-					batch.removeAttribute( root, 'b' );
+					batch.removeAttribute( 'b', root );
 					expect( spy.callCount ).to.equal( 0 );
 				} );
 			} );
@@ -1319,7 +1319,7 @@ describe( 'Batch', () => {
 				} );
 
 				it( 'should clear attributes on root element', () => {
-					batch.setAttributes( root, { a: 1, b: 2, c: 3 } );
+					batch.setAttributes( { a: 1, b: 2, c: 3 }, root );
 
 					expect( Array.from( root.getAttributeKeys() ).length ).to.equal( 3 );
 
@@ -1345,11 +1345,11 @@ describe( 'Batch', () => {
 			const nodeB = new Element( 'p', { b: 2 } );
 			root.insertChildren( 0, [ nodeA, nodeB ] );
 
-			batch.setAttribute( nodeA, 'a', 1 );
+			batch.setAttribute( 'a', 1, nodeA );
 
 			expect( batch.deltas.length ).to.equal( 0 );
 
-			batch.removeAttribute( Range.createIn( root ), 'x' );
+			batch.removeAttribute( 'x', Range.createIn( root ) );
 
 			expect( batch.deltas.length ).to.equal( 0 );
 		} );
@@ -1376,7 +1376,7 @@ describe( 'Batch', () => {
 			// such a big amount of the same tests, so let's use a spy here.
 			const spy = sinon.spy( batch, 'setAttribute' );
 
-			batch.setAttributes( range, { a: 3, c: null } );
+			batch.setAttributes( { a: 3, c: null }, range );
 
 			// Verify result.
 			expect( Array.from( frag.getChild( 0 ).getAttributes() ) ).to.deep.equal( [ [ 'a', 3 ] ] );
@@ -1384,8 +1384,8 @@ describe( 'Batch', () => {
 
 			// Verify operations
 			sinon.assert.calledTwice( spy );
-			sinon.assert.calledWith( spy.firstCall, range, 'a', 3 );
-			sinon.assert.calledWith( spy.secondCall, range, 'c', null );
+			sinon.assert.calledWith( spy.firstCall, 'a', 3, range );
+			sinon.assert.calledWith( spy.secondCall, 'c', null, range );
 		} );
 
 		it( 'should set attributes one by one on range for map as attributes list', () => {
@@ -1395,7 +1395,7 @@ describe( 'Batch', () => {
 			// such a big amount of the same tests, so let's use a spy here.
 			const spy = sinon.spy( batch, 'setAttribute' );
 
-			batch.setAttributes( range, new Map( [ [ 'a', 3 ], [ 'c', null ] ] ) );
+			batch.setAttributes( new Map( [ [ 'a', 3 ], [ 'c', null ] ] ), range );
 
 			// Verify result.
 			expect( Array.from( frag.getChild( 0 ).getAttributes() ) ).to.deep.equal( [ [ 'a', 3 ] ] );
@@ -1403,8 +1403,8 @@ describe( 'Batch', () => {
 
 			// Verify operations
 			sinon.assert.calledTwice( spy );
-			sinon.assert.calledWith( spy.firstCall, range, 'a', 3 );
-			sinon.assert.calledWith( spy.secondCall, range, 'c', null );
+			sinon.assert.calledWith( spy.firstCall, 'a', 3, range );
+			sinon.assert.calledWith( spy.secondCall, 'c', null, range );
 		} );
 
 		it( 'should set attributes one by one on item', () => {
@@ -1412,15 +1412,15 @@ describe( 'Batch', () => {
 			// such a big amount of the same tests, so let's use a spy here.
 			const spy = sinon.spy( batch, 'setAttribute' );
 
-			batch.setAttributes( item, { a: 3, c: null } );
+			batch.setAttributes( { a: 3, c: null }, item );
 
 			// Verify result.
 			expect( Array.from( item.getAttributes() ) ).to.deep.equal( [ [ 'b', 2 ], [ 'a', 3 ] ] );
 
 			// Verify operations
 			sinon.assert.calledTwice( spy );
-			sinon.assert.calledWith( spy.firstCall, item, 'a', 3 );
-			sinon.assert.calledWith( spy.secondCall, item, 'c', null );
+			sinon.assert.calledWith( spy.firstCall, 'a', 3, item );
+			sinon.assert.calledWith( spy.secondCall, 'c', null, item );
 		} );
 
 		it( 'should set attributes one by one on item for maps as attributes list', () => {
@@ -1428,15 +1428,15 @@ describe( 'Batch', () => {
 			// such a big amount of the same tests, so let's use a spy here.
 			const spy = sinon.spy( batch, 'setAttribute' );
 
-			batch.setAttributes( item, new Map( [ [ 'a', 3 ], [ 'c', null ] ] ) );
+			batch.setAttributes( new Map( [ [ 'a', 3 ], [ 'c', null ] ] ), item );
 
 			// Verify result.
 			expect( Array.from( item.getAttributes() ) ).to.deep.equal( [ [ 'b', 2 ], [ 'a', 3 ] ] );
 
 			// Verify operations
 			sinon.assert.calledTwice( spy );
-			sinon.assert.calledWith( spy.firstCall, item, 'a', 3 );
-			sinon.assert.calledWith( spy.secondCall, item, 'c', null );
+			sinon.assert.calledWith( spy.firstCall, 'a', 3, item );
+			sinon.assert.calledWith( spy.secondCall, 'c', null, item );
 		} );
 	} );