ソースを参照

Change let to const.

Szymon Cofalik 9 年 前
コミット
367b4b272e

+ 7 - 8
packages/ckeditor5-engine/src/command/attributecommand.js

@@ -112,16 +112,16 @@ export default class AttributeCommand extends Command {
 	 * otherwise command will remove attribute. If not set, command will look for it's current value to decide what it should do.
 	 */
 	_execute( forceValue ) {
-		let document = this.editor.document;
-		let selection = document.selection;
-		let value = ( forceValue === undefined ) ? !this.value : forceValue;
+		const document = this.editor.document;
+		const selection = document.selection;
+		const value = ( forceValue === undefined ) ? !this.value : forceValue;
 
 		if ( selection.isCollapsed ) {
 			let selectionParent = selection.getFirstPosition().parent;
 
 			if ( selectionParent.getChildCount() === 0 ) {
 				// If selection is collapsed and in empty node, operate on stored selection attributes.
-				let storeKey = Selection.getStoreAttributeKey( this.attributeKey );
+				const storeKey = Selection.getStoreAttributeKey( this.attributeKey );
 
 				document.enqueueChanges( () => {
 					if ( value ) {
@@ -141,11 +141,10 @@ export default class AttributeCommand extends Command {
 		} else if ( selection.hasAnyRange ) {
 			// If selection is not collapsed and has ranges, we change attribute on those ranges.
 			document.enqueueChanges( () => {
-				let ranges = selection.getRanges();
-				ranges = this._getSchemaValidRanges( ranges );
+				const ranges = this._getSchemaValidRanges( selection.getRanges() );
 
 				// Keep it as one undo step.
-				let batch = document.batch();
+				const batch = document.batch();
 
 				for ( let range of ranges ) {
 					if ( value ) {
@@ -167,7 +166,7 @@ export default class AttributeCommand extends Command {
 	 * @private
 	 */
 	_getSchemaValidRanges( ranges ) {
-		let validRanges = [];
+		const validRanges = [];
 
 		for ( let range of ranges ) {
 			const walker = new TreeWalker( { boundaries: range, mergeCharacters: true } );

+ 5 - 5
packages/ckeditor5-engine/src/treemodel/document.js

@@ -228,13 +228,13 @@ export default class Document {
 		if ( !this.selection.hasAnyRange ) {
 			this.selection.clearAttributes();
 		} else {
-			let position = this.selection.getFirstPosition();
-			let positionParent = position.parent;
+			const position = this.selection.getFirstPosition();
+			const positionParent = position.parent;
 			let attrs = null;
 
 			if ( this.selection.isCollapsed === false ) {
 				// 1. If selection is a range...
-				let range = this.selection.getFirstRange();
+				const range = this.selection.getFirstRange();
 
 				// ...look for a first character node in that range and take attributes from it.
 				for ( let item of range ) {
@@ -247,8 +247,8 @@ export default class Document {
 
 			// 2. If the selection is a caret or the range does not contain a character node...
 			if ( !attrs && this.selection.isCollapsed === true ) {
-				let nodeBefore = positionParent.getChild( position.offset - 1 );
-				let nodeAfter = positionParent.getChild( position.offset );
+				const nodeBefore = positionParent.getChild( position.offset - 1 );
+				const nodeAfter = positionParent.getChild( position.offset );
 
 				// ...look at the node before caret and take attributes from it if it is a character node.
 				attrs = getAttrsIfCharacter( nodeBefore );

+ 4 - 4
packages/ckeditor5-engine/src/treemodel/schema.js

@@ -94,8 +94,8 @@ export class SchemaItem {
 	 * @private
 	 */
 	_getPaths( type, attribute ) {
-		let source = type === 'ALLOW' ? this._allowed : this._disallowed;
-		let paths = [];
+		const source = type === 'ALLOW' ? this._allowed : this._disallowed;
+		const paths = [];
 
 		for ( let item of source ) {
 			if ( item.attribute === attribute ) {
@@ -129,7 +129,7 @@ export class SchemaItem {
 				// Every item name is expanded to all names of items that item is extending.
 				// So, if on item path, there is an item that is extended by item from checked path, it will
 				// also be treated as matching.
-				let chain = this._schema._extensionChains.get( checkName );
+				const chain = this._schema._extensionChains.get( checkName );
 
 				// Since our paths have to match in given order, we always check against first item from item path.
 				// So, if item path is: B D E
@@ -393,7 +393,7 @@ export default class Schema {
 	 * @private
 	 */
 	static _makeItemsPathFromPosition( position ) {
-		let path = [];
+		const path = [];
 		let parent = position.parent;
 
 		while ( parent !== null ) {