Procházet zdrojové kódy

Internal (utils): Cosmetic tweaks in Collection class.

Marek Lewandowski před 5 roky
rodič
revize
584dc18a01
1 změnil soubory, kde provedl 4 přidání a 6 odebrání
  1. 4 6
      packages/ckeditor5-utils/src/collection.js

+ 4 - 6
packages/ckeditor5-utils/src/collection.js

@@ -199,9 +199,7 @@ export default class Collection {
 	addMany( items, index ) {
 	addMany( items, index ) {
 		if ( index === undefined ) {
 		if ( index === undefined ) {
 			index = this._items.length;
 			index = this._items.length;
-		}
-
-		if ( index > this._items.length || index < 0 ) {
+		} else if ( index > this._items.length || index < 0 ) {
 			/**
 			/**
 			 * The index number has invalid value.
 			 * The index number has invalid value.
 			 *
 			 *
@@ -213,8 +211,8 @@ export default class Collection {
 		for ( let offset = 0; offset < items.length; offset++ ) {
 		for ( let offset = 0; offset < items.length; offset++ ) {
 			const item = items[ offset ];
 			const item = items[ offset ];
 			const itemId = this._getItemIdBeforeAdding( item );
 			const itemId = this._getItemIdBeforeAdding( item );
-
 			const currentItemIndex = index + offset;
 			const currentItemIndex = index + offset;
+
 			this._items.splice( currentItemIndex, 0, item );
 			this._items.splice( currentItemIndex, 0, item );
 			this._itemMap.set( itemId, item );
 			this._itemMap.set( itemId, item );
 
 
@@ -355,7 +353,7 @@ export default class Collection {
 			this._bindToCollection = null;
 			this._bindToCollection = null;
 		}
 		}
 
 
-		const removedItems = [ ...this._items ];
+		const removedItems = Array.from( this._items );
 
 
 		while ( this.length ) {
 		while ( this.length ) {
 			this._remove( 0, true );
 			this._remove( 0, true );
@@ -664,7 +662,7 @@ export default class Collection {
 	 *
 	 *
 	 * @private
 	 * @private
 	 * @param {Object} subject The item to remove, its id or index in the collection.
 	 * @param {Object} subject The item to remove, its id or index in the collection.
-	 * @param {Boolean} [skipChange] If `true` no change event is fired.
+	 * @param {Boolean} [skipChange] If `true` no {@link #event:change} event is fired.
 	 * @returns {Object} The removed item.
 	 * @returns {Object} The removed item.
 	 * @fires remove
 	 * @fires remove
 	 * @fires change
 	 * @fires change