commit f376db070519056f475b891764ee92bbce3697e4
parent 27ab9869be894c6302b9d95dfc76462b927e8df1
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 13 May 2015 11:45:45 -0400
Remove duplicate Zotero.defineProperty() function
Ended up in two places somehow
Diffstat:
1 file changed, 7 insertions(+), 40 deletions(-)
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -1435,6 +1435,13 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
Object.defineProperty(obj, prop, d);
}
+ this.extendClass = function(superClass, newClass) {
+ newClass._super = superClass;
+ newClass.prototype = Object.create(superClass.prototype);
+ newClass.prototype.constructor = newClass;
+ }
+
+
/*
* This function should be removed
*
@@ -1621,46 +1628,6 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
/**
- * Defines property on the object
- * More compact way to do Object.defineProperty
- *
- * @param {Object} obj Target object
- * @param {String} prop Property to be defined
- * @param {Object} desc Propery descriptor. If not overriden, "enumerable" is true
- * @param {Object} opts Options:
- * lateInit {Boolean} If true, the _getter_ is intended for late
- * initialization of the property. The getter is replaced with a simple
- * property once initialized.
- */
- this.defineProperty = function(obj, prop, desc, opts) {
- if (typeof prop != 'string') throw new Error("Property must be a string");
- var d = { __proto__: null, enumerable: true, configurable: true }; // Enumerable by default
- for (let p in desc) {
- if (!desc.hasOwnProperty(p)) continue;
- d[p] = desc[p];
- }
-
- if (opts) {
- if (opts.lateInit && d.get) {
- let getter = d.get;
- d.get = function() {
- var val = getter.call(this);
- this[prop] = val; // Replace getter with value
- return val;
- }
- }
- }
-
- Object.defineProperty(obj, prop, d);
- }
-
- this.extendClass = function(superClass, newClass) {
- newClass._super = superClass;
- newClass.prototype = Object.create(superClass.prototype);
- newClass.prototype.constructor = newClass;
- }
-
- /**
* Allow other events (e.g., UI updates) on main thread to be processed if necessary
*
* @param {Integer} [timeout=50] Maximum number of milliseconds to wait