瀏覽代碼

Replaced var with let or const.

Piotrek Koszuliński 10 年之前
父節點
當前提交
aea50efc47

+ 7 - 7
packages/ckeditor5-utils/src/collection.js

@@ -81,8 +81,8 @@ CKEDITOR.define( [ 'emittermixin', 'ckeditorerror', 'utils' ], function( Emitter
 		 * @param {Object} item
 		 */
 		add( item ) {
-			var itemId;
-			var idProperty = this._idProperty;
+			let itemId;
+			const idProperty = this._idProperty;
 
 			if ( ( idProperty in item ) ) {
 				itemId = item[ idProperty ];
@@ -124,7 +124,7 @@ CKEDITOR.define( [ 'emittermixin', 'ckeditorerror', 'utils' ], function( Emitter
 		 * @returns {Object} The requested item or `null` if such item does not exist.
 		 */
 		get( idOrIndex ) {
-			var item;
+			let item;
 
 			if ( typeof idOrIndex == 'string' ) {
 				item = this._itemMap.get( idOrIndex );
@@ -149,9 +149,9 @@ CKEDITOR.define( [ 'emittermixin', 'ckeditorerror', 'utils' ], function( Emitter
 		 * @returns {Object} The removed item.
 		 */
 		remove( subject ) {
-			var index, id, item;
-			var itemDoesNotExist = false;
-			var idProperty = this._idProperty;
+			let index, id, item;
+			let itemDoesNotExist = false;
+			const idProperty = this._idProperty;
 
 			if ( typeof subject == 'string' ) {
 				id = subject;
@@ -245,7 +245,7 @@ CKEDITOR.define( [ 'emittermixin', 'ckeditorerror', 'utils' ], function( Emitter
 		 * @returns {String} The next id.
 		 */
 		_getNextId() {
-			var id;
+			let id;
 
 			do {
 				id = String( this._nextId++ );

+ 6 - 6
packages/ckeditor5-utils/src/config.js

@@ -76,17 +76,17 @@ CKEDITOR.define( [ 'model', 'utils' ], function( Model, utils ) {
 
 			// The target for this configuration is, for now, this object.
 			//jscs:disable safeContextKeyword
-			var target = this;
+			let target = this;
 			//jscs:enable
 
 			// The configuration name should be split into parts if it has dots. E.g: `resize.width`.
-			var parts = name.toLowerCase().split( '.' );
+			const parts = name.toLowerCase().split( '.' );
 
 			// Take the name of the configuration out of the parts. E.g. `resize.width` -> `width`
 			name = parts.pop();
 
 			// Retrieves the final target for this configuration recursively.
-			for ( var i = 0; i < parts.length; i++ ) {
+			for ( let i = 0; i < parts.length; i++ ) {
 				// The target will always be an instance of Config.
 				if ( !( target[ parts[ i ] ] instanceof Config ) ) {
 					target.set( parts[ i ], new Config() );
@@ -132,17 +132,17 @@ CKEDITOR.define( [ 'model', 'utils' ], function( Model, utils ) {
 		get( name ) {
 			// The target for this configuration is, for now, this object.
 			//jscs:disable safeContextKeyword
-			var source = this;
+			let source = this;
 			//jscs:enable
 
 			// The configuration name should be split into parts if it has dots. E.g. `resize.width` -> [`resize`, `width`]
-			var parts = name.toLowerCase().split( '.' );
+			const parts = name.toLowerCase().split( '.' );
 
 			// Take the name of the configuration from the parts. E.g. `resize.width` -> `width`
 			name = parts.pop();
 
 			// Retrieves the source for this configuration recursively.
-			for ( var i = 0; i < parts.length; i++ ) {
+			for ( let i = 0; i < parts.length; i++ ) {
 				// The target will always be an instance of Config.
 				if ( !( source[ parts[ i ] ] instanceof Config ) ) {
 					source = null;

+ 7 - 7
packages/ckeditor5-utils/src/document/attribute.js

@@ -53,7 +53,7 @@ CKEDITOR.define( [ 'utils' ], function( utils ) {
 			// We do not care about the order, so collections with the same elements should return the same hash.
 			function sort( key, value ) {
 				if ( !utils.isArray( value ) && utils.isObject( value ) ) {
-					var sorted = {};
+					const sorted = {};
 
 					// Sort keys and fill up the sorted object.
 					Object.keys( value ).sort().forEach( function( key ) {
@@ -71,8 +71,8 @@ CKEDITOR.define( [ 'utils' ], function( utils ) {
 		 * Compares two attributes. Returns `true` if two attributes have the same key and value even if the order of keys
 		 * in the value object is different.
 		 *
-		 *		var attr1 = new Attribute( 'foo', { a: 1, b: 2 } );
-		 *		var attr2 = new Attribute( 'foo', { b: 2, a: 1 } );
+		 *		let attr1 = new Attribute( 'foo', { a: 1, b: 2 } );
+		 *		let attr2 = new Attribute( 'foo', { b: 2, a: 1 } );
 		 *		attr1.isEqual( attr2 ); // true
 		 *
 		 * @param {document.Attribute} otherAttr Attribute to compare with.
@@ -88,9 +88,9 @@ CKEDITOR.define( [ 'utils' ], function( utils ) {
 		 *
 		 * Note that attributes are registered globally.
 		 *
-		 *		var attr1 = Attribute.register( 'bold', true );
-		 *		var attr2 = Attribute.register( 'bold', true );
-		 *		var attr3 = new Attribute( 'bold', true );
+		 *		let attr1 = Attribute.register( 'bold', true );
+		 *		let attr2 = Attribute.register( 'bold', true );
+		 *		let attr3 = new Attribute( 'bold', true );
 		 *		attr1 === attr2 // true
 		 *		attr1 === attr3 // true
 		 *
@@ -100,7 +100,7 @@ CKEDITOR.define( [ 'utils' ], function( utils ) {
 		 * @returns {document.Attribute} Registered attribute.
 		 */
 		static register( key, value ) {
-			var attr = new Attribute( key, value );
+			const attr = new Attribute( key, value );
 
 			if ( this._register[ attr._hash ] ) {
 				return this._register[ attr._hash ];

+ 2 - 2
packages/ckeditor5-utils/src/document/document.js

@@ -12,7 +12,7 @@ CKEDITOR.define( [
 	'utils',
 	'ckeditorerror'
 ], function( Element, RootElement, EmitterMixin, utils, CKEditorError ) {
-	var graveyardSymbol = Symbol( 'graveyard' );
+	const graveyardSymbol = Symbol( 'graveyard' );
 
 	/**
 	 * Document model.
@@ -92,7 +92,7 @@ CKEDITOR.define( [
 				);
 			}
 
-			var root = new RootElement( this );
+			const root = new RootElement( this );
 			this.roots.set( name, root );
 
 			return root;

+ 2 - 2
packages/ckeditor5-utils/src/document/element.js

@@ -60,7 +60,7 @@ CKEDITOR.define( [ 'document/node', 'document/nodelist' ], function( Node, NodeL
 		insertChildren( index, nodes ) {
 			this._children.insert( index, new NodeList( nodes ) );
 
-			for ( var node of this._children ) {
+			for ( let node of this._children ) {
 				node.parent = this;
 			}
 		}
@@ -77,7 +77,7 @@ CKEDITOR.define( [ 'document/node', 'document/nodelist' ], function( Node, NodeL
 		 */
 
 		removeChildren( index, number ) {
-			for ( var i = index; i < index + number; i++ ) {
+			for ( let i = index; i < index + number; i++ ) {
 				this._children.get( i ).parent = null;
 			}
 

+ 14 - 14
packages/ckeditor5-utils/src/document/node.js

@@ -49,7 +49,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @returns {Number|Null} Index of the node in the parent element or null if the node has not parent.
 		 */
 		getIndex() {
-			var pos;
+			let pos;
 
 			if ( !this.parent ) {
 				return null;
@@ -75,8 +75,8 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @property {Number} depth
 		 */
 		get depth() {
-			var depth = 0;
-			var parent = this.parent;
+			let depth = 0;
+			let parent = this.parent;
 
 			while ( parent ) {
 				depth++;
@@ -94,7 +94,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @property {Number} depth
 		 */
 		get root() {
-			var root = this; // jscs:ignore safeContextKeyword
+			let root = this; // jscs:ignore safeContextKeyword
 
 			while ( root.parent ) {
 				root = root.parent;
@@ -110,7 +110,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @property {document.Node|null} nextSibling
 		 */
 		get nextSibling() {
-			var index = this.getIndex();
+			const index = this.getIndex();
 
 			return ( index !== null && this.parent.getChild( index + 1 ) ) || null;
 		}
@@ -122,7 +122,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @property {document.Node|null} previousSibling
 		 */
 		get previousSibling() {
-			var index = this.getIndex();
+			const index = this.getIndex();
 
 			return ( index !== null && this.parent.getChild( index - 1 ) ) || null;
 		}
@@ -135,7 +135,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @returns {Boolean} True if node contains given attribute or an attribute with the given key.
 		 */
 		hasAttr( key ) {
-			var attr;
+			let attr;
 
 			// Attribute.
 			if ( key instanceof Attribute ) {
@@ -164,7 +164,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @returns {document.Attribute} The found attribute.
 		 */
 		getAttr( key ) {
-			for ( var attr of this._attrs ) {
+			for ( let attr of this._attrs ) {
 				if ( attr.key == key ) {
 					return attr.value;
 				}
@@ -179,7 +179,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @param {String} key The attribute key.
 		 */
 		removeAttr( key ) {
-			for ( var attr of this._attrs ) {
+			for ( let attr of this._attrs ) {
 				if ( attr.key == key ) {
 					this._attrs.delete( attr );
 
@@ -206,8 +206,8 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @returns {Number[]} The path.
 		 */
 		getPath() {
-			var path = [];
-			var node = this; // jscs:ignore safeContextKeyword
+			const path = [];
+			let node = this; // jscs:ignore safeContextKeyword
 
 			while ( node.parent ) {
 				path.unshift( node.getIndex() );
@@ -223,7 +223,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @returns {Object} Clone of this object with the parent property replaced with its name.
 		 */
 		toJSON() {
-			var json = utils.clone( this );
+			const json = utils.clone( this );
 
 			// Due to circular references we need to remove parent reference.
 			json.parent = this.parent ? this.parent.name : null;
@@ -238,9 +238,9 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], function( A
 		 * @returns {Number} Number of attributes.
 		 */
 		_getAttrCount() {
-			var count = 0;
+			let count = 0;
 
-			for ( var attr of this._attrs ) { // jshint ignore:line
+			for ( let attr of this._attrs ) { // jshint ignore:line
 				count++;
 			}
 

+ 8 - 8
packages/ckeditor5-utils/src/document/nodelist.js

@@ -25,26 +25,26 @@ CKEDITOR.define( [
 		/**
 		 * Constructor let you create a list of nodes in many ways. See examples:
 		 *
-		 *		var nodeList = new NodeList( [ new Element( p1 ), new Element( p1 ) ] );
+		 *		let nodeList = new NodeList( [ new Element( p1 ), new Element( p1 ) ] );
 		 *		nodeList.length; // 2
 		 *
-		 *		var nodeList = new NodeList( new Element( p ) );
+		 *		let nodeList = new NodeList( new Element( p ) );
 		 *		nodeList.length; // 1
 		 *
-		 *		var nodeList = new NodeList( [ 'foo', new Element( p ), 'bar' ] );
+		 *		let nodeList = new NodeList( [ 'foo', new Element( p ), 'bar' ] );
 		 *		nodeList.length; // 7
 		 *
-		 *		var nodeList = new NodeList( 'foo' );
+		 *		let nodeList = new NodeList( 'foo' );
 		 *		nodeList.length; // 3
 		 *
-		 *		var nodeList = new NodeList( new Text( 'foo', [ new Attribute( 'bar', 'bom' ) ] ) );
+		 *		let nodeList = new NodeList( new Text( 'foo', [ new Attribute( 'bar', 'bom' ) ] ) );
 		 *		nodeList.length; // 3
 		 *		nodeList.get( 0 ).getAttr( 'bar' ); // 'bom'
 		 *		nodeList.get( 1 ).getAttr( 'bar' ); // 'bom'
 		 *		nodeList.get( 2 ).getAttr( 'bar' ); // 'bom'
 		 *
-		 *		var nodeListA = new NodeList( 'foo' );
-		 *		var nodeListB = new NodeList( nodeListA );
+		 *		let nodeListA = new NodeList( 'foo' );
+		 *		let nodeListB = new NodeList( nodeListA );
 		 *		nodeListA === nodeListB // true
 		 *		nodeListB.length // 3
 		 *
@@ -66,7 +66,7 @@ CKEDITOR.define( [
 			this._nodes = [];
 
 			if ( nodes ) {
-				var node, character;
+				let node, character;
 
 				if ( !utils.isIterable( nodes ) ) {
 					nodes = [ nodes ];

+ 3 - 3
packages/ckeditor5-utils/src/document/operation/changeoperation.js

@@ -59,9 +59,9 @@ CKEDITOR.define( [ 'document/operation/operation', 'ckeditorerror' ], function(
 		}
 
 		_execute() {
-			var oldAttr = this.oldAttr;
-			var newAttr = this.newAttr;
-			var value;
+			const oldAttr = this.oldAttr;
+			const newAttr = this.newAttr;
+			let value;
 
 			if ( oldAttr !== null && newAttr !== null && oldAttr.key != newAttr.key ) {
 				/**

+ 8 - 8
packages/ckeditor5-utils/src/document/operation/moveoperation.js

@@ -52,10 +52,10 @@ CKEDITOR.define( [
 		}
 
 		_execute() {
-			var sourceElement = this.sourcePosition.parent;
-			var targetElement = this.targetPosition.parent;
-			var sourceOffset = this.sourcePosition.offset;
-			var targetOffset = this.targetPosition.offset;
+			let sourceElement = this.sourcePosition.parent;
+			let targetElement = this.targetPosition.parent;
+			let sourceOffset = this.sourcePosition.offset;
+			let targetOffset = this.targetPosition.offset;
 
 			// Validate whether move operation has correct parameters.
 			// Validation is pretty complex but move operation is one of the core ways to manipulate the document state.
@@ -88,11 +88,11 @@ CKEDITOR.define( [
 					'operation-move-range-into-itself: Trying to move a range of nodes to the inside of that range.'
 				);
 			} else {
-				var sourcePath = this.sourcePosition.getParentPath();
-				var targetPath = this.targetPosition.getParentPath();
+				const sourcePath = this.sourcePosition.getParentPath();
+				const targetPath = this.targetPosition.getParentPath();
 
 				if ( utils.compareArrays( sourcePath, targetPath ) == utils.compareArrays.PREFIX ) {
-					var i = sourcePath.length;
+					let i = sourcePath.length;
 
 					if ( this.targetPosition.path[ i ] >= sourceOffset && this.targetPosition.path[ i ] < sourceOffset + this.howMany ) {
 						/**
@@ -114,7 +114,7 @@ CKEDITOR.define( [
 				targetOffset -= this.howMany;
 			}
 
-			var removedNodes = sourceElement.removeChildren( sourceOffset, this.howMany );
+			const removedNodes = sourceElement.removeChildren( sourceOffset, this.howMany );
 
 			targetElement.insertChildren( targetOffset, removedNodes );
 		}

+ 2 - 2
packages/ckeditor5-utils/src/document/operation/removeoperation.js

@@ -25,10 +25,10 @@ CKEDITOR.define( [
 		 * @constructor
 		 */
 		constructor( position, howMany, baseVersion ) {
-			var graveyard = position.root.document._graveyard;
+			const graveyard = position.root.document._graveyard;
 
 			// Position in a graveyard where nodes were moved.
-			var graveyardPosition = Position.createFromParentAndOffset( graveyard, 0 );
+			const graveyardPosition = Position.createFromParentAndOffset( graveyard, 0 );
 
 			super( position, graveyardPosition, howMany, baseVersion );
 		}

+ 3 - 3
packages/ckeditor5-utils/src/document/position.js

@@ -55,9 +55,9 @@ CKEDITOR.define( [ 'utils', 'ckeditorerror' ], function( utils, CKEditorError )
 		 * @property {document.Element} parent
 		 */
 		get parent() {
-			var parent = this.root;
+			let parent = this.root;
 
-			var i, len;
+			let i, len;
 
 			for ( i = 0, len = this.path.length - 1; i < len; i++ ) {
 				parent = parent.getChild( this.path[ i ] );
@@ -125,7 +125,7 @@ CKEDITOR.define( [ 'utils', 'ckeditorerror' ], function( utils, CKEditorError )
 		 * @returns {document.Position}
 		 */
 		static createFromParentAndOffset( parent, offset ) {
-			var path = parent.getPath();
+			const path = parent.getPath();
 
 			path.push( offset );
 

+ 6 - 6
packages/ckeditor5-utils/src/document/positioniterator.js

@@ -64,8 +64,8 @@ CKEDITOR.define( [
 		 * @returns {document.Node} return.value.node Encountered node.
 		 */
 		next() {
-			var position = this.position;
-			var parent = position.parent;
+			const position = this.position;
+			const parent = position.parent;
 
 			// We are at the end of the root.
 			if ( parent.parent === null && position.offset === parent.getChildCount() ) {
@@ -76,7 +76,7 @@ CKEDITOR.define( [
 				return { done: true };
 			}
 
-			var nodeAfter = position.nodeAfter;
+			const nodeAfter = position.nodeAfter;
 
 			if ( nodeAfter instanceof Element ) {
 				this.position = Position.createFromParentAndOffset( nodeAfter, 0 );
@@ -104,8 +104,8 @@ CKEDITOR.define( [
 		 * @returns {document.Node} return.value.node Scanned node.
 		 */
 		previous() {
-			var position = this.position;
-			var parent = position.parent;
+			const position = this.position;
+			const parent = position.parent;
 
 			// We are at the beginning of the root.
 			if ( parent.parent === null && position.offset === 0 ) {
@@ -116,7 +116,7 @@ CKEDITOR.define( [
 				return { done: true };
 			}
 
-			var nodeBefore = position.nodeBefore;
+			const nodeBefore = position.nodeBefore;
 
 			if ( nodeBefore instanceof Element ) {
 				this.position = Position.createFromParentAndOffset( nodeBefore, nodeBefore.getChildCount() );

+ 15 - 15
packages/ckeditor5-utils/src/emittermixin.js

@@ -25,7 +25,7 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 		 * Lower values are called first.
 		 */
 		on( event, callback, ctx, priority ) {
-			var callbacks = getCallbacks( this, event );
+			const callbacks = getCallbacks( this, event );
 
 			// Set the priority defaults.
 			if ( typeof priority != 'number' ) {
@@ -39,7 +39,7 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 			};
 
 			// Add the callback to the list in the right priority position.
-			for ( var i = callbacks.length - 1; i >= 0; i-- ) {
+			for ( let i = callbacks.length - 1; i >= 0; i-- ) {
 				if ( callbacks[ i ].priority <= priority ) {
 					callbacks.splice( i + 1, 0, callback );
 
@@ -62,7 +62,7 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 		 * Lower values are called first.
 		 */
 		once( event, callback, ctx, priority ) {
-			var onceCallback = function( event ) {
+			const onceCallback = function( event ) {
 				// Go off() at the first call.
 				event.off();
 
@@ -83,13 +83,13 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 		 * the same callback is used several times with different contexts.
 		 */
 		off( event, callback, ctx ) {
-			var callbacks = getCallbacksIfAny( this, event );
+			const callbacks = getCallbacksIfAny( this, event );
 
 			if ( !callbacks ) {
 				return;
 			}
 
-			for ( var i = 0; i < callbacks.length; i++ ) {
+			for ( let i = 0; i < callbacks.length; i++ ) {
 				if ( callbacks[ i ].callback == callback ) {
 					if ( !ctx || ctx == callbacks[ i ].ctx ) {
 						// Remove the callback from the list (fixing the next index).
@@ -111,7 +111,7 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 		 * Lower values are called first.
 		 */
 		listenTo( emitter, event, callback, ctx, priority ) {
-			var emitters, emitterId, emitterInfo, eventCallbacks;
+			let emitters, emitterId, emitterInfo, eventCallbacks;
 
 			// _listeningTo contains a list of emitters that this object is listening to.
 			// This list has the following format:
@@ -167,10 +167,10 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 		 * `event`.
 		 */
 		stopListening( emitter, event, callback ) {
-			var emitters = this._listeningTo;
-			var emitterId = emitter && emitter._emitterId;
-			var emitterInfo = emitters && emitterId && emitters[ emitterId ];
-			var eventCallbacks = emitterInfo && event && emitterInfo.callbacks[ event ];
+			let emitters = this._listeningTo;
+			let emitterId = emitter && emitter._emitterId;
+			let emitterInfo = emitters && emitterId && emitters[ emitterId ];
+			let eventCallbacks = emitterInfo && event && emitterInfo.callbacks[ event ];
 
 			// Stop if nothing has been listened.
 			if ( !emitters || ( emitter && !emitterInfo ) || ( event && !eventCallbacks ) ) {
@@ -214,19 +214,19 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 		 * @param {...*} [args] Additional arguments to be passed to the callbacks.
 		 */
 		fire( event, args ) {
-			var callbacks = getCallbacksIfAny( this, event );
+			const callbacks = getCallbacksIfAny( this, event );
 
 			if ( !callbacks ) {
 				return;
 			}
 
-			var eventInfo = new EventInfo( this, event );
+			let eventInfo = new EventInfo( this, event );
 
 			// Take the list of arguments to pass to the callbacks.
 			args = Array.prototype.slice.call( arguments, 1 );
 			args.unshift( eventInfo );
 
-			for ( var i = 0; i < callbacks.length; i++ ) {
+			for ( let i = 0; i < callbacks.length; i++ ) {
 				callbacks[ i ].callback.apply( callbacks[ i ].ctx, args );
 
 				// Remove the callback from future requests if off() has been called.
@@ -262,7 +262,7 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 
 	// Gets the list of callbacks for a given event.
 	function getCallbacks( source, eventName ) {
-		var events = getEvents( source );
+		const events = getEvents( source );
 
 		if ( !events[ eventName ] ) {
 			events[ eventName ] = [];
@@ -273,7 +273,7 @@ CKEDITOR.define( [ 'eventinfo', 'utils' ], function( EventInfo, utils ) {
 
 	// Get the list of callbacks for a given event only if there is any available.
 	function getCallbacksIfAny( source, event ) {
-		var callbacks;
+		let callbacks;
 
 		if ( !source._events || !( callbacks = source._events[ event ] ) || !callbacks.length ) {
 			return null;

+ 1 - 1
packages/ckeditor5-utils/src/log.js

@@ -40,7 +40,7 @@
  */
 
 CKEDITOR.define( function() {
-	var log = {
+	const log = {
 		/**
 		 * Logs an error to the console.
 		 *

+ 2 - 2
packages/ckeditor5-utils/src/model.js

@@ -71,7 +71,7 @@ CKEDITOR.define( [ 'emittermixin', 'ckeditorerror', 'utils' ], function( Emitter
 				 * This error is thrown when trying to {@link Model#set set} an attribute with
 				 * a name of an already existing property. For example:
 				 *
-				 *		var model = new Model();
+				 *		let model = new Model();
 				 *		model.property = 1;
 				 *		model.set( 'property', 2 );		// throws
 				 *
@@ -92,7 +92,7 @@ CKEDITOR.define( [ 'emittermixin', 'ckeditorerror', 'utils' ], function( Emitter
 				},
 
 				set: function( value ) {
-					var oldValue = this._attributes[ name ];
+					const oldValue = this._attributes[ name ];
 
 					if ( oldValue !== value ) {
 						this._attributes[ name ] = value;

+ 1 - 1
packages/ckeditor5-utils/src/utils-lodash.js

@@ -16,7 +16,7 @@
 ( function() {
 	// The list of Lo-Dash methods to include in "utils".
 	// It is mandatory to execute `grunt lodash` after changes to this list.
-	var lodashInclude = [
+	const lodashInclude = [
 		/**
 		 * See Lo-Dash: https://lodash.com/docs#clone
 		 *

+ 9 - 8
packages/ckeditor5-utils/src/utils.js

@@ -13,7 +13,7 @@
  */
 
 CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], function( lodashIncludes, lodash ) {
-	var utils = {
+	const utils = {
 		/**
 		 * Creates a spy function (ala Sinon.js) that can be used to inspect call to it.
 		 *
@@ -24,11 +24,9 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], function( lod
 		 * @returns {Function} The spy function.
 		 */
 		spy() {
-			var spy = function() {
+			return function spy() {
 				spy.called = true;
 			};
-
-			return spy;
 		},
 
 		/**
@@ -38,7 +36,7 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], function( lod
 		 * @returns {Number} A number representing the id.
 		 */
 		uid: ( function() {
-			var next = 1;
+			let next = 1;
 
 			return function() {
 				return next++;
@@ -71,9 +69,9 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], function( lod
 		 * `a` is a {@link utils.compareArrays#EXTENSION extension}, or `a` is {@link utils.compareArrays#DIFFERENT different}.
 		 */
 		compareArrays( a, b ) {
-			var minLen = Math.min( a.length, b.length );
+			const minLen = Math.min( a.length, b.length );
 
-			for ( var i = 0; i < minLen; i++ ) {
+			for ( let i = 0; i < minLen; i++ ) {
 				if ( a[ i ] != b[ i ] ) {
 					// The arrays are different.
 					return utils.compareArrays.DIFFERENT;
@@ -100,18 +98,21 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], function( lod
 	 * @type {Number}
 	 */
 	utils.compareArrays.SAME = 0;
+
 	/**
 	 * Flag for "is a prefix of" relation between arrays.
 	 *
 	 * @type {Number}
 	 */
 	utils.compareArrays.PREFIX = 1;
+
 	/**
 	 * Flag for "is a suffix of" relation between arrays.
 	 *
 	 * @type {number}
 	 */
 	utils.compareArrays.EXTENSION = 2;
+
 	/**
 	 * Flag for "is different than" relation between arrays.
 	 *
@@ -120,7 +121,7 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], function( lod
 	utils.compareArrays.DIFFERENT = 3;
 
 	// Extend "utils" with Lo-Dash methods.
-	for ( var i = 0; i < lodashIncludes.length; i++ ) {
+	for ( let i = 0; i < lodashIncludes.length; i++ ) {
 		utils[ lodashIncludes[ i ] ] = lodash[ lodashIncludes[ i ] ];
 	}