From fa039971e6875bbf209f7f6f2062e36ead310cac Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 13 May 2015 13:43:05 -0400 Subject: [PATCH] Fixes #714, Zotero.defineProperty() lazy mode doesn't work Patch from @aurimasv --- chrome/content/zotero/xpcom/zotero.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 10701314a5..33c98f1ce5 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1424,9 +1424,17 @@ Components.utils.import("resource://gre/modules/osfile.jsm"); if (opts) { if (opts.lazy && d.get) { let getter = d.get; + d.configurable = true; // Make sure we can change the property later d.get = function() { - var val = getter.call(this); - this[prop] = val; // Replace getter with value + let val = getter.call(this); + + // Redefine getter on this object as non-writable value + delete d.set; + delete d.get; + d.writable = false; + d.value = val; + Object.defineProperty(this, prop, d); + return val; } }