Browse Source

PR fixes.

Maksymilian Barnaś 9 years ago
parent
commit
0c52ec2cd2
1 changed files with 6 additions and 7 deletions
  1. 6 7
      packages/ckeditor5-core/src/command/toggleattributecommand.js

+ 6 - 7
packages/ckeditor5-core/src/command/toggleattributecommand.js

@@ -82,10 +82,9 @@ export default class ToggleAttributeCommand extends Command {
 	 * @param {engine.model.Batch} [options.batch] Batch to group undo steps.
 	 */
 	_doExecute( options = {} ) {
-		const { forceValue, batch } = options;
 		const document = this.editor.document;
 		const selection = document.selection;
-		const value = ( forceValue === undefined ) ? !this.value : forceValue;
+		const value = ( options.forceValue === undefined ) ? !this.value : options.forceValue;
 
 		// If selection has non-collapsed ranges, we change attribute on nodes inside those ranges.
 		document.enqueueChanges( () => {
@@ -96,16 +95,16 @@ export default class ToggleAttributeCommand extends Command {
 					selection.removeAttribute( this.attributeKey );
 				}
 			} else {
-				const workRanges = getSchemaValidRanges( this.attributeKey, selection.getRanges(), document.schema );
+				const ranges = getSchemaValidRanges( this.attributeKey, selection.getRanges(), document.schema );
 
 				// Keep it as one undo step.
-				const workBatch = batch || document.batch();
+				const batch = options.batch || document.batch();
 
-				for ( let range of workRanges ) {
+				for ( let range of ranges ) {
 					if ( value ) {
-						workBatch.setAttribute( range, this.attributeKey, value );
+						batch.setAttribute( range, this.attributeKey, value );
 					} else {
-						workBatch.removeAttribute( range, this.attributeKey );
+						batch.removeAttribute( range, this.attributeKey );
 					}
 				}
 			}