Kaynağa Gözat

Docs: Added API docs for the _getItemId method.

Also changed the name from _getItemIdBeforeAdding to _getItemId - as the method logic is not really related to adding.
Marek Lewandowski 5 yıl önce
ebeveyn
işleme
1bc5495e0b
1 değiştirilmiş dosya ile 11 ekleme ve 2 silme
  1. 11 2
      packages/ckeditor5-utils/src/collection.js

+ 11 - 2
packages/ckeditor5-utils/src/collection.js

@@ -128,7 +128,7 @@ export default class Collection {
 		if ( hasInitialItems ) {
 			for ( const item of initialItemsOrOptions ) {
 				this._items.push( item );
-				this._itemMap.set( this._getItemIdBeforeAdding( item ), item );
+				this._itemMap.set( this._getItemId( item ), item );
 			}
 		}
 
@@ -648,7 +648,16 @@ export default class Collection {
 		} );
 	}
 
-	_getItemIdBeforeAdding( item ) {
+	/**
+	 * Returns an unique id property for a given `item`.
+	 *
+	 * The method will generate new id and assign it to the `item` if it doesn't have any.
+	 *
+	 * @private
+	 * @param {Object} item Item to be added.
+	 * @returns {String}
+	 */
+	_getItemId( item ) {
 		const idProperty = this._idProperty;
 		let itemId;