diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index d3a76ef51c..0e937bd770 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1815,7 +1815,7 @@ Zotero.Utilities = { * @param {Object} cslItem */ "itemFromCSLJSON":function(item, cslItem) { - var isZoteroItem = item instanceof Zotero.Item, + var isZoteroItem = !!item.setType, zoteroType; // Some special cases to help us map item types correctly diff --git a/test/tests/utilitiesTest.js b/test/tests/utilitiesTest.js index 23cda017f9..8105fc0452 100644 --- a/test/tests/utilitiesTest.js +++ b/test/tests/utilitiesTest.js @@ -384,6 +384,19 @@ describe("Zotero.Utilities", function() { assert.equal(item.getField('title'), jsonAttachment.title, 'title imported correctly'); }); + // For Zotero.Item created in translation sandbox in connectors + it("should not depend on Zotero.Item existing", function* () { + let item = new Zotero.Item; + var Item = Zotero.Item; + delete Zotero.Item; + assert.throws(() => "" instanceof Zotero.Item); + + let data = loadSampleData('citeProcJSExport'); + assert.doesNotThrow(Zotero.Utilities.itemFromCSLJSON.bind(Zotero.Utilities, item, Object.values(data)[0])); + + Zotero.Item = Item; + assert.doesNotThrow(() => "" instanceof Zotero.Item); + }) }); describe("#ellipsize()", function () {