fx-compat: __defineGetter__()defineProperty()

This commit is contained in:
Dan Stillman 2022-05-06 02:33:24 -04:00
parent 13b9837524
commit f8e10f80cc

View file

@ -26,7 +26,6 @@
// Commonly used imports accessible anywhere // Commonly used imports accessible anywhere
Components.utils.importGlobalProperties(["XMLHttpRequest"]); Components.utils.importGlobalProperties(["XMLHttpRequest"]);
Components.utils.import("resource://zotero/config.js"); Components.utils.import("resource://zotero/config.js");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/osfile.jsm"); Components.utils.import("resource://gre/modules/osfile.jsm");
Components.classes["@mozilla.org/net/osfileconstantsservice;1"] Components.classes["@mozilla.org/net/osfileconstantsservice;1"]
@ -53,7 +52,10 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
this.initialized = false; this.initialized = false;
this.skipLoading = false; this.skipLoading = false;
this.startupError; this.startupError;
this.__defineGetter__("startupErrorHandler", function() { return _startupErrorHandler; }); Object.defineProperty(this, 'startupErrorHandler', {
get: () => _startupErrorHandler,
enumerable: true
});
this.version; this.version;
this.platform; this.platform;
this.locale; this.locale;
@ -87,20 +89,27 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
* @property {Boolean} locked Whether all Zotero panes are locked * @property {Boolean} locked Whether all Zotero panes are locked
* with an overlay * with an overlay
*/ */
this.__defineGetter__('locked', function () { return _locked; }); Object.defineProperty(
this.__defineSetter__('locked', function (lock) { this,
var wasLocked = _locked; 'locked',
_locked = lock; {
get: () => _locked,
if (!wasLocked && lock) { set: (lock) => {
this.unlockDeferred = Zotero.Promise.defer(); var wasLocked = _locked;
this.unlockPromise = this.unlockDeferred.promise; _locked = lock;
if (!wasLocked && lock) {
this.unlockDeferred = Zotero.Promise.defer();
this.unlockPromise = this.unlockDeferred.promise;
}
else if (wasLocked && !lock) {
Zotero.debug("Running unlock callbacks");
this.unlockDeferred.resolve();
}
},
enumerable: true
} }
else if (wasLocked && !lock) { );
Zotero.debug("Running unlock callbacks");
this.unlockDeferred.resolve();
}
});
/** /**
* @property {Boolean} crashed - True if the application needs to be restarted * @property {Boolean} crashed - True if the application needs to be restarted