Convert arrays passed to Z.selectItems to objects

This commit is contained in:
Simon Kornblith 2012-07-30 14:54:05 -04:00
parent 59913cc5c0
commit 9e75aba8fd

View File

@ -424,6 +424,15 @@ Zotero.Translate.Sandbox = {
throw new Error("Translator called select items with no items");
}
// Some translators pass an array rather than an object to Zotero.selectItems.
// This will break messaging outside of Firefox, so we need to fix it.
if(Object.prototype.toString.call(items) === "[object Array]") {
translate._debug("WARNING: Zotero.selectItems should be called with an object, not an array");
var itemsObj = {};
for(var i in items) itemsObj[i] = items[i];
items = itemsObj;
}
if(translate._selectedItems) {
// if we have a set of selected items for this translation, use them
return translate._selectedItems;