Allow Zotero.Item instance instead of itemID in Collection.hasItem()

This commit is contained in:
Dan Stillman 2018-12-16 02:16:11 -05:00
parent 80f6b857f6
commit 5f07f36ae5

View file

@ -450,11 +450,16 @@ Zotero.Collection.prototype.removeItems = Zotero.Promise.coroutine(function* (it
/**
* Check if an item belongs to the collection
**/
Zotero.Collection.prototype.hasItem = function(itemID) {
* Check if an item belongs to the collection
*
* @param {Zotero.Item|Number} item - Item or itemID
*/
Zotero.Collection.prototype.hasItem = function (item) {
this._requireData('childItems');
return this._childItems.has(itemID);
if (item instanceof Zotero.Item) {
item = item.id;
}
return this._childItems.has(item);
}