From a9d142c83a7dc66c046fdcf716d86ecedd8cc782 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 24 Jan 2019 19:07:56 -0500 Subject: [PATCH] Fx60: Replace Object.watch() in locateManager --- chrome/content/zotero/xpcom/locateManager.js | 28 ++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/xpcom/locateManager.js b/chrome/content/zotero/xpcom/locateManager.js index 66b83913b0..39b54a6e25 100644 --- a/chrome/content/zotero/xpcom/locateManager.js +++ b/chrome/content/zotero/xpcom/locateManager.js @@ -277,17 +277,14 @@ Zotero.LocateManager = new function() { * @param {Object} [obj] The locate engine, in parsed form, as it was serialized to JSON */ var LocateEngine = function(obj) { - this.alias = this.name = "Untitled"; - this.description = this._urlTemplate = this.icon = null; - this.hidden = false; + this._alias = this._name = "Untitled"; + this._description = null; + this._icon = null; + this._hidden = false; + this._urlTemplate = null; this._urlParams = []; if(obj) for(var prop in obj) this[prop] = obj[prop]; - - // Queue deferred serialization whenever a property is modified - for (let prop of ["alias", "name", "description", "icon", "hidden"]) { - this.watch(prop, _watchLocateEngineProperties); - } } LocateEngine.prototype = { @@ -488,4 +485,19 @@ Zotero.LocateManager = new function() { this.icon = OS.Path.toFileURI(iconFile); } } + + // Queue deferred serialization whenever a property is modified + for (let prop of ["alias", "name", "description", "icon", "hidden"]) { + let propName = '_' + prop; + Object.defineProperty(LocateEngine.prototype, prop, { + get: function () { + return this[propName]; + }, + set: function (val) { + var oldVal = this[propName]; + this[propName] = val; + _watchLocateEngineProperties(prop, oldVal, val); + } + }); + } }