www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit a09ff9c9ec036cf5783cd11cf4a371e14f6cd909
parent 5857368131f4f4508e8174aeaed74217090db675
Author: Simon Kornblith <simon@simonster.com>
Date:   Mon,  1 Sep 2014 18:42:24 -0400

Don't unwrap objects passed to chrome

Unwrapping objects also waives the Xray wrappers for contained objects,
which we need.

Diffstat:
Mchrome/content/zotero/xpcom/openurl.js | 19+++++++++++--------
Mchrome/content/zotero/xpcom/translation/translate_firefox.js | 10----------
Mchrome/content/zotero/xpcom/utilities.js | 3+++
3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/chrome/content/zotero/xpcom/openurl.js b/chrome/content/zotero/xpcom/openurl.js @@ -243,6 +243,13 @@ Zotero.OpenURL = new function() { if(asObj) return entries; return entries.join("&"); } + + function _cloneIfNecessary(obj1, obj2) { + if(Zotero.isFx && !Zotero.isBookmarklet && Zotero.platformMajorVersion >= 32) { + return Components.utils.cloneInto(obj1, obj2); + } + return obj1; + } /* * Generates an item in the format returned by item.fromArray() given an @@ -380,14 +387,14 @@ Zotero.OpenURL = new function() { if(complexAu.length && !lastCreator.lastName && !lastCreator.institutional) { lastCreator.lastName = value; } else { - complexAu.push({lastName:value, creatorType:(key == "rft.aulast" ? "author" : "inventor"), offset:item.creators.length}); + complexAu.push(_cloneIfNecessary({lastName:value, creatorType:(key == "rft.aulast" ? "author" : "inventor"), offset:item.creators.length}, item)); } } else if(key == "rft.aufirst" || key == "rft.invfirst") { var lastCreator = complexAu[complexAu.length-1]; if(complexAu.length && !lastCreator.firstName && !lastCreator.institutional) { lastCreator.firstName = value; } else { - complexAu.push({firstName:value, creatorType:(key == "rft.aufirst" ? "author" : "inventor"), offset:item.creators.length}); + complexAu.push(_cloneIfNecessary({firstName:value, creatorType:(key == "rft.aufirst" ? "author" : "inventor"), offset:item.creators.length}, item)); } } else if(key == "rft.au" || key == "rft.creator" || key == "rft.contributor" || key == "rft.inventor") { if(key == "rft.contributor") { @@ -398,13 +405,9 @@ Zotero.OpenURL = new function() { var type = "author"; } - if(value.indexOf(",") !== -1) { - item.creators.push(Zotero.Utilities.cleanAuthor(value, type, true)); - } else { - item.creators.push(Zotero.Utilities.cleanAuthor(value, type, false)); - } + item.creators.push(_cloneIfNecessary(Zotero.Utilities.cleanAuthor(value, type, value.indexOf(",") !== -1), item)); } else if(key == "rft.aucorp") { - complexAu.push({lastName:value, isInstitution:true}); + complexAu.push(_cloneIfNecessary({lastName:value, isInstitution:true}, item)); } else if(key == "rft.isbn" && !item.ISBN) { item.ISBN = value; } else if(key == "rft.pub" || key == "rft.publisher") { diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -462,16 +462,6 @@ Zotero.Translate.SandboxManager.prototype = { if(isFunction) { attachTo[localKey] = function() { var args = Array.prototype.slice.apply(arguments); - if(Zotero.platformMajorVersion >= 32) { - // This is necessary on Nightly and works - // fine on 31, but apparently breaks - // ZU.xpath in an unusual way on 24 - for(var i=0; i<args.length; i++) { - if(typeof args[i] === "object" && args[i] !== null && args[i].wrappedJSObject) { - args[i] = args[i].wrappedJSObject; - } - } - } if(passAsFirstArgument) args.unshift(passAsFirstArgument); return me._copyObject(object[localKey].apply(object, args)); }; diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -910,6 +910,9 @@ Zotero.Utilities = { * @param {Function} onDone Function to call when done */ "processAsync":function (sets, callbacks, onDone) { + if(sets.wrappedJSObject) sets = sets.wrappedJSObject; + if(callbacks.wrappedJSObject) callbacks = callbacks.wrappedJSObject; + var currentSet; var index = 0;