Преглед изворни кода

Merge pull request #540 from ckeditor/t/482

Batch setAttr and removeAttr method fixes
Szymon Cofalik пре 9 година
родитељ
комит
38fefeeb24

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

@@ -14,9 +14,9 @@ import RootElement from '../rootelement.js';
 import Element from '../element.js';
 
 /**
- * To provide specific OT behavior and better collisions solving, methods to change attributes ({@link engine.model.Batch#setAttr}
- * and {@link engine.model.Batch#removeAttr}) use `AttributeDelta` class which inherits from the `Delta` class and may
- * overwrite some methods.
+ * To provide specific OT behavior and better collisions solving, methods to change attributes
+ * ({@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
  * @extends engine.model.delta.Delta
@@ -87,8 +87,8 @@ export default class AttributeDelta extends Delta {
 }
 
 /**
- * To provide specific OT behavior and better collisions solving, methods to change attributes ({@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, methods to change attributes ({@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
@@ -107,12 +107,12 @@ export class RootAttributeDelta extends Delta {
  * Sets value of the attribute with given key on a {@link engine.model.Item model item} or on a {@link engine.model.Range range}.
  *
  * @chainable
- * @method engine.model.Batch#setAttr
+ * @method engine.model.Batch#setAttribute
+ * @param {engine.model.Item|engine.model.Range} itemOrRange Model item or range on which the attribute will be set.
  * @param {String} key Attribute key.
  * @param {*} value Attribute new value.
- * @param {engine.model.Item|engine.model.Range} itemOrRange Model item or range on which the attribute will be set.
  */
-register( 'setAttr', function( key, value, itemOrRange ) {
+register( 'setAttribute', function( itemOrRange, key, value ) {
 	attribute( this, key, value, itemOrRange );
 
 	return this;
@@ -122,11 +122,11 @@ register( 'setAttr', function( key, value, itemOrRange ) {
  * Removes an attribute with given key from a {@link engine model.Item model item} or from a {@link engine.model.Range range}.
  *
  * @chainable
- * @method engine.model.Batch#removeAttr
- * @param {String} key Attribute key.
  * @param {engine.model.Item|engine.model.Range} itemOrRange Model item or range from which the attribute will be removed.
+ * @method engine.model.Batch#removeAttribute
+ * @param {String} key Attribute key.
  */
-register( 'removeAttr', function( key, itemOrRange ) {
+register( 'removeAttribute', function( itemOrRange, key ) {
 	attribute( this, key, null, itemOrRange );
 
 	return this;

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

@@ -224,7 +224,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 );
 			} );
 		}
 	}
@@ -244,7 +244,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 );
 			} );
 		}
 	}
@@ -265,13 +265,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 ] );
 				}
 			} );
 		}

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

@@ -124,12 +124,12 @@ export default class AttributeOperation extends Operation {
 				/**
 				 * The attribute with given key already exists for the given node.
 				 *
-				 * @error operation-attribute-attr-exists
+				 * @error attribute-operation-attribute-exists
 				 * @param {engine.model.Node} node
 				 * @param {String} key
 				 */
 				throw new CKEditorError(
-					'operation-attribute-attr-exists: The attribute with given key already exists.',
+					'attribute-operation-attribute-exists: The attribute with given key already exists.',
 					{ node: item, key: this.key }
 				);
 			}

+ 8 - 8
packages/ckeditor5-engine/src/model/operation/moveoperation.js

@@ -123,28 +123,28 @@ export default class MoveOperation extends Operation {
 			/**
 			 * Source position or target position is invalid.
 			 *
-			 * @error operation-move-position-invalid
+			 * @error move-operation-position-invalid
 			 */
 			throw new CKEditorError(
-				'operation-move-position-invalid: Source position or target position is invalid.'
+				'move-operation-position-invalid: Source position or target position is invalid.'
 			);
 		} else if ( sourceOffset + this.howMany > sourceElement.getMaxOffset() ) {
 			/**
 			 * The nodes which should be moved do not exist.
 			 *
-			 * @error operation-move-nodes-do-not-exist
+			 * @error move-operation-nodes-do-not-exist
 			 */
 			throw new CKEditorError(
-				'operation-move-nodes-do-not-exist: The nodes which should be moved do not exist.'
+				'move-operation-nodes-do-not-exist: The nodes which should be moved do not exist.'
 			);
 		} else if ( sourceElement === targetElement && sourceOffset < targetOffset && targetOffset < sourceOffset + this.howMany ) {
 			/**
 			 * Trying to move a range of nodes into the middle of that range.
 			 *
-			 * @error operation-move-range-into-itself
+			 * @error move-operation-range-into-itself
 			 */
 			throw new CKEditorError(
-				'operation-move-range-into-itself: Trying to move a range of nodes to the inside of that range.'
+				'move-operation-range-into-itself: Trying to move a range of nodes to the inside of that range.'
 			);
 		} else if ( this.sourcePosition.root == this.targetPosition.root ) {
 			if ( compareArrays( this.sourcePosition.getParentPath(), this.targetPosition.getParentPath() ) == 'prefix' ) {
@@ -154,10 +154,10 @@ export default class MoveOperation extends Operation {
 					/**
 					 * Trying to move a range of nodes into one of nodes from that range.
 					 *
-					 * @error operation-move-node-into-itself
+					 * @error move-operation-node-into-itself
 					 */
 					throw new CKEditorError(
-						'operation-move-node-into-itself: Trying to move a range of nodes into one of nodes from that range.'
+						'move-operation-node-into-itself: Trying to move a range of nodes into one of nodes from that range.'
 					);
 				}
 			}

+ 5 - 5
packages/ckeditor5-engine/src/model/operation/rootattributeoperation.js

@@ -93,13 +93,13 @@ export default class RootAttributeOperation extends Operation {
 			/**
 			 * The attribute which should be removed does not exists for the given node.
 			 *
-			 * @error operation-rootattribute-no-attr-to-remove
+			 * @error rootattribute-operation-wrong-old-value
 			 * @param {engine.model.RootElement} root
 			 * @param {String} key
 			 * @param {*} value
 			 */
 			throw new CKEditorError(
-				'operation-rootattribute-no-attr-to-remove: The attribute which should be removed does not exists for given node.',
+				'rootattribute-operation-wrong-old-value: Changed node has different attribute value than operation\'s old attribute value.',
 				{ root: this.root, key: this.key }
 			);
 		}
@@ -108,12 +108,12 @@ export default class RootAttributeOperation extends Operation {
 			/**
 			 * The attribute with given key already exists for the given node.
 			 *
-			 * @error operation-rootattribute-attr-exists
+			 * @error rootattribute-operation-attribute-exists
 			 * @param {engine.model.RootElement} root
 			 * @param {String} key
 			 */
 			throw new CKEditorError(
-				'operation-rootattribute-attr-exists: The attribute with given key already exists.',
+				'rootattribute-operation-attribute-exists: The attribute with given key already exists.',
 				{ root: this.root, key: this.key }
 			);
 		}
@@ -150,7 +150,7 @@ export default class RootAttributeOperation extends Operation {
 			 * @param {String} rootName
 			 */
 			throw new CKEditorError(
-				'rootattributeoperation-fromjson-no-root: Cannot create RootAttributeOperation. Root with specified name does not exist.',
+				'rootattribute-operation-fromjson-no-root: Cannot create RootAttributeOperation. Root with specified name does not exist.',
 				{ rootName: json }
 			);
 		}

+ 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;
 		} );
@@ -391,8 +391,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 ) => {
@@ -409,8 +409,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 );
@@ -428,8 +428,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

@@ -54,76 +54,76 @@ describe( 'Batch', () => {
 			root.insertChildren( 0, [ node, text ] );
 		} );
 
-		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, text );
+				batch.setAttribute( text, '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, text );
+				batch.setAttribute( text, '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', text );
+				batch.removeAttribute( text, '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;
 			} );
@@ -172,44 +172,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------' );
 			} );
@@ -220,7 +220,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---' );
@@ -232,7 +232,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-' );
@@ -244,75 +244,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------' );
 			} );
@@ -323,40 +323,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;
 			} );
@@ -364,38 +364,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/model/operation/attributeoperation.js

@@ -312,7 +312,7 @@ describe( 'AttributeOperation', () => {
 					doc.version
 				)
 			) );
-		} ).to.throw( CKEditorError, /operation-attribute-attr-exists/ );
+		} ).to.throw( CKEditorError, /attribute-operation-attribute-exists/ );
 	} );
 
 	it( 'should create an AttributeOperation with the same parameters when cloned', () => {

+ 4 - 4
packages/ckeditor5-engine/tests/model/operation/moveoperation.js

@@ -161,7 +161,7 @@ describe( 'MoveOperation', () => {
 			doc.version
 		);
 
-		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /operation-move-nodes-do-not-exist/ );
+		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /move-operation-nodes-do-not-exist/ );
 	} );
 
 	it( 'should throw an error if target or source parent-element specified by position does not exist', () => {
@@ -178,7 +178,7 @@ describe( 'MoveOperation', () => {
 
 		root.removeChildren( 1 );
 
-		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /operation-move-position-invalid/ );
+		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /move-operation-position-invalid/ );
 	} );
 
 	it( 'should throw an error if operation tries to move a range between the beginning and the end of that range', () => {
@@ -191,7 +191,7 @@ describe( 'MoveOperation', () => {
 			doc.version
 		);
 
-		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /operation-move-range-into-itself/ );
+		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /move-operation-range-into-itself/ );
 	} );
 
 	it( 'should throw an error if operation tries to move a range into a sub-tree of a node that is in that range', () => {
@@ -205,7 +205,7 @@ describe( 'MoveOperation', () => {
 			doc.version
 		);
 
-		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /operation-move-node-into-itself/ );
+		expect( () => doc.applyOperation( wrapInDelta( operation ) ) ).to.throw( CKEditorError, /move-operation-node-into-itself/ );
 	} );
 
 	it( 'should not throw an error if operation move a range into a sibling', () => {

+ 3 - 3
packages/ckeditor5-engine/tests/model/operation/rootattributeoperation.js

@@ -186,7 +186,7 @@ describe( 'RootAttributeOperation', () => {
 					doc.version
 				)
 			) );
-		} ).to.throw( CKEditorError, /operation-rootattribute-no-attr-to-remove/ );
+		} ).to.throw( CKEditorError, /rootattribute-operation-wrong-old-value/ );
 	} );
 
 	it( 'should throw an error when one try to insert and the attribute already exists', () => {
@@ -202,7 +202,7 @@ describe( 'RootAttributeOperation', () => {
 					doc.version
 				)
 			) );
-		} ).to.throw( CKEditorError, /operation-rootattribute-attr-exists/ );
+		} ).to.throw( CKEditorError, /rootattribute-operation-attribute-exists/ );
 	} );
 
 	it( 'should create a RootAttributeOperation with the same parameters when cloned', () => {
@@ -271,7 +271,7 @@ describe( 'RootAttributeOperation', () => {
 
 			expect( () => {
 				RootAttributeOperation.fromJSON( serialized, doc );
-			} ).to.throw( CKEditorError, /rootattributeoperation-fromjson-no-root/ );
+			} ).to.throw( CKEditorError, /rootattribute-operation-fromjson-no-roo/ );
 		} );
 	} );
 } );

+ 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' );