From 5f07f36ae5f12992d21a22def76f976b432f71bd Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 16 Dec 2018 02:16:11 -0500 Subject: [PATCH] Allow Zotero.Item instance instead of itemID in Collection.hasItem() --- chrome/content/zotero/xpcom/data/collection.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index 13c5813e0c..6aaaaf827c 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -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); }