Переглянути джерело

Merge pull request #596 from ckeditor/t/585

Changed: parameters order in RenameDelta.
Piotr Jasiun 9 роки тому
батько
коміт
ba3a4166b9

+ 2 - 2
packages/ckeditor5-engine/src/model/delta/renamedelta.js

@@ -43,10 +43,10 @@ function apply( batch, delta, operation ) {
  *
  * @chainable
  * @method engine.model.Batch#rename
- * @param {String} newName New element name.
  * @param {engine.model.Element} element The element to rename.
+ * @param {String} newName New element name.
  */
-register( 'rename', function( newName, element ) {
+register( 'rename', function( element, newName ) {
 	if ( !( element instanceof Element ) ) {
 		/**
 		 * Trying to rename an object which is not an instance of Element.

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

@@ -116,7 +116,7 @@ describe( 'ModelConversionDispatcher', () => {
 
 			dispatcher.on( 'rename', cbRename );
 
-			doc.batch().rename( 'figure', image );
+			doc.batch().rename( image, 'figure' );
 
 			expect( cbRename.called );
 		} );

+ 1 - 1
packages/ckeditor5-engine/tests/editingcontroller.js

@@ -162,7 +162,7 @@ describe( 'EditingController', () => {
 			expect( getViewData( editing.view ) ).to.equal( '<p>f{}oo</p><p></p><p>bar</p>' );
 
 			model.enqueueChanges( () => {
-				model.batch().rename( 'div', modelRoot.getChild( 0 ) );
+				model.batch().rename( modelRoot.getChild( 0 ), 'div' );
 			} );
 
 			expect( getViewData( editing.view ) ).to.equal( '<div>f{}oo</div><p></p><p>bar</p>' );

+ 4 - 4
packages/ckeditor5-engine/tests/model/delta/renamedelta.js

@@ -24,7 +24,7 @@ describe( 'Batch', () => {
 
 		batch = doc.batch();
 
-		chain = batch.rename( 'h', p );
+		chain = batch.rename( p, 'h' );
 	} );
 
 	describe( 'rename', () => {
@@ -36,7 +36,7 @@ describe( 'Batch', () => {
 
 		it( 'should throw if not an Element instance is passed', () => {
 			expect( () => {
-				batch.rename( 'h', new Text( 'abc' ) );
+				batch.rename( new Text( 'abc' ), 'h' );
 			} ).to.throw( CKEditorError, /^batch-rename-not-element-instance/ );
 		} );
 
@@ -46,7 +46,7 @@ describe( 'Batch', () => {
 
 		it( 'should add delta to batch and operation to delta before applying operation', () => {
 			sinon.spy( doc, 'applyOperation' );
-			batch.rename( 'p', root.getChild( 0 ) );
+			batch.rename( root.getChild( 0 ), 'p' );
 
 			const correctDeltaMatcher = sinon.match( operation => {
 				return operation.delta && operation.delta.batch && operation.delta.batch == batch;
@@ -84,7 +84,7 @@ describe( 'RenameDelta', () => {
 
 			const batch = doc.batch();
 
-			batch.rename( 'h', root.getChild( 0 ) );
+			batch.rename( root.getChild( 0 ), 'h' );
 
 			const reversed = batch.deltas[ 0 ].getReversed();