Selaa lähdekoodia

Aligned code to with new Batch#setAttributes API.

Oskar Wróbel 8 vuotta sitten
vanhempi
commit
94b01cbe03

+ 3 - 3
packages/ckeditor5-image/src/imagestyle/imagestylecommand.js

@@ -20,7 +20,7 @@ export default class ImageStyleCommand extends Command {
 	 * Creates an instance of the image style command. Each command instance is handling one style.
 	 *
 	 * @param {module:core/editor/editor~Editor} editor The editor instance.
-	 * @param {module:image/imagestyle/imagestyleengine~ImageStyleFormat} styles A style to be applied by this command.
+	 * @param {module:image/imagestyle/imagestyleengine~ImageStyleFormat} style A style to be applied by this command.
 	 */
 	constructor( editor, style ) {
 		super( editor );
@@ -82,9 +82,9 @@ export default class ImageStyleCommand extends Command {
 			// Default style means that there is no `imageStyle` attribute in the model.
 			// https://github.com/ckeditor/ckeditor5-image/issues/147
 			if ( this.style.isDefault ) {
-				batch.removeAttribute( imageElement, 'imageStyle' );
+				batch.removeAttribute( 'imageStyle', imageElement );
 			} else {
-				batch.setAttribute( imageElement, 'imageStyle', this.style.name );
+				batch.setAttribute( 'imageStyle', this.style.name, imageElement );
 			}
 		} );
 	}

+ 1 - 1
packages/ckeditor5-image/src/imagetextalternative/imagetextalternativecommand.js

@@ -55,7 +55,7 @@ export default class ImageTextAlternativeCommand extends Command {
 		doc.enqueueChanges( () => {
 			const batch = options.batch || doc.batch();
 
-			batch.setAttribute( imageElement, 'alt', options.newValue );
+			batch.setAttribute( 'alt', options.newValue, imageElement );
 		} );
 	}
 }

+ 4 - 4
packages/ckeditor5-image/tests/image/converters.js

@@ -139,7 +139,7 @@ describe( 'Image converters', () => {
 			document.enqueueChanges( () => {
 				const batch = document.batch();
 
-				batch.setAttribute( image, 'alt', 'foo bar' );
+				batch.setAttribute( 'alt', 'foo bar', image );
 			} );
 
 			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -154,7 +154,7 @@ describe( 'Image converters', () => {
 			document.enqueueChanges( () => {
 				const batch = document.batch();
 
-				batch.removeAttribute( image, 'alt' );
+				batch.removeAttribute( 'alt', image );
 			} );
 
 			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -169,7 +169,7 @@ describe( 'Image converters', () => {
 			document.enqueueChanges( () => {
 				const batch = document.batch();
 
-				batch.setAttribute( image, 'alt', 'baz quix' );
+				batch.setAttribute( 'alt', 'baz quix', image );
 			} );
 
 			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -188,7 +188,7 @@ describe( 'Image converters', () => {
 			document.enqueueChanges( () => {
 				const batch = document.batch();
 
-				batch.setAttribute( image, 'alt', 'baz quix' );
+				batch.setAttribute( 'alt', 'baz quix', image );
 			} );
 
 			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(

+ 7 - 7
packages/ckeditor5-image/tests/image/imageengine.js

@@ -113,7 +113,7 @@ describe( 'ImageEngine', () => {
 				document.enqueueChanges( () => {
 					const batch = document.batch();
 
-					batch.removeAttribute( image, 'srcset' );
+					batch.removeAttribute( 'srcset', image );
 				} );
 
 				expect( editor.getData() ).to.equal(
@@ -419,7 +419,7 @@ describe( 'ImageEngine', () => {
 				document.enqueueChanges( () => {
 					const batch = document.batch();
 
-					batch.setAttribute( image, 'alt', 'new text' );
+					batch.setAttribute( 'alt', 'new text', image );
 				} );
 
 				expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -434,7 +434,7 @@ describe( 'ImageEngine', () => {
 				document.enqueueChanges( () => {
 					const batch = document.batch();
 
-					batch.removeAttribute( image, 'alt' );
+					batch.removeAttribute( 'alt', image );
 				} );
 
 				expect( getViewData( viewDocument, { withoutSelection: true } ) )
@@ -452,7 +452,7 @@ describe( 'ImageEngine', () => {
 				document.enqueueChanges( () => {
 					const batch = document.batch();
 
-					batch.removeAttribute( image, 'alt' );
+					batch.removeAttribute( 'alt', image );
 				} );
 
 				expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -487,7 +487,7 @@ describe( 'ImageEngine', () => {
 				document.enqueueChanges( () => {
 					const batch = document.batch();
 
-					batch.removeAttribute( image, 'srcset' );
+					batch.removeAttribute( 'srcset', image );
 				} );
 
 				expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -519,7 +519,7 @@ describe( 'ImageEngine', () => {
 				document.enqueueChanges( () => {
 					const batch = document.batch();
 
-					batch.removeAttribute( image, 'srcset' );
+					batch.removeAttribute( 'srcset', image );
 				} );
 
 				expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -541,7 +541,7 @@ describe( 'ImageEngine', () => {
 				document.enqueueChanges( () => {
 					const batch = document.batch();
 
-					batch.removeAttribute( image, 'srcset' );
+					batch.removeAttribute( 'srcset', image );
 				} );
 
 				expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(

+ 1 - 1
packages/ckeditor5-image/tests/imagecaption/imagecaptionengine.js

@@ -314,7 +314,7 @@ describe( 'ImageCaptionEngine', () => {
 			const batch = doc.batch();
 
 			doc.enqueueChanges( () => {
-				batch.setAttribute( image, 'alt', 'alt text' );
+				batch.setAttribute( 'alt', 'alt text', image );
 			} );
 
 			expect( getModelData( doc, { withoutSelection: true } ) ).to.equal(

+ 10 - 10
packages/ckeditor5-image/tests/imagestyle/imagestyleengine.js

@@ -131,7 +131,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', 'sideStyle' );
+				batch.setAttribute( 'imageStyle', 'sideStyle', image );
 			} );
 
 			expect( editor.getData() ).to.equal( '<figure class="image side-class"><img src="foo.png"></figure>' );
@@ -146,7 +146,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', null );
+				batch.setAttribute( 'imageStyle', null, image );
 			} );
 
 			expect( editor.getData() ).to.equal( '<figure class="image"><img src="foo.png"></figure>' );
@@ -161,7 +161,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', 'sideStyle' );
+				batch.setAttribute( 'imageStyle', 'sideStyle', image );
 			} );
 
 			expect( editor.getData() ).to.equal( '<figure class="image side-class"><img src="foo.png"></figure>' );
@@ -172,7 +172,7 @@ describe( 'ImageStyleEngine', () => {
 			);
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', 'dummyStyle' );
+				batch.setAttribute( 'imageStyle', 'dummyStyle', image );
 			} );
 
 			expect( editor.getData() ).to.equal( '<figure class="image dummy-class"><img src="foo.png"></figure>' );
@@ -193,7 +193,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', 'sideStyle' );
+				batch.setAttribute( 'imageStyle', 'sideStyle', image );
 			} );
 
 			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -211,7 +211,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', null );
+				batch.setAttribute( 'imageStyle', null, image );
 			} );
 
 			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -229,7 +229,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', 'sideStyle' );
+				batch.setAttribute( 'imageStyle', 'sideStyle', image );
 			} );
 
 			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
@@ -243,7 +243,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', 'foo' );
+				batch.setAttribute( 'imageStyle', 'foo', image );
 			} );
 
 			expect( editor.getData() ).to.equal( '<figure class="image"><img src="foo.png"></figure>' );
@@ -258,7 +258,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', 'foo' );
+				batch.setAttribute( 'imageStyle', 'foo', image );
 			} );
 
 			expect( editor.getData() ).to.equal( '<figure class="image"><img src="foo.png"></figure>' );
@@ -273,7 +273,7 @@ describe( 'ImageStyleEngine', () => {
 			const batch = document.batch();
 
 			document.enqueueChanges( () => {
-				batch.setAttribute( image, 'imageStyle', null );
+				batch.setAttribute( 'imageStyle', null, image );
 			} );
 
 			expect( editor.getData() ).to.equal( '<figure class="image"><img src="foo.png"></figure>' );