diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js index a7a9b7ce5..8452e9e0a 100644 --- a/chrome/content/zotero/xpcom/data/dataObject.js +++ b/chrome/content/zotero/xpcom/data/dataObject.js @@ -55,17 +55,17 @@ Zotero.DataObject = function () { Zotero.DataObject.prototype._objectType = 'dataObject'; Zotero.DataObject.prototype._dataTypes = []; -Zotero.Utilities.Internal.defineProperty(Zotero.DataObject.prototype, 'objectType', { +Zotero.defineProperty(Zotero.DataObject.prototype, 'objectType', { get: function() this._objectType }); -Zotero.Utilities.Internal.defineProperty(Zotero.DataObject.prototype, 'libraryKey', { +Zotero.defineProperty(Zotero.DataObject.prototype, 'libraryKey', { get: function() this._libraryID + "/" + this._key }); -Zotero.Utilities.Internal.defineProperty(Zotero.DataObject.prototype, 'parentKey', { +Zotero.defineProperty(Zotero.DataObject.prototype, 'parentKey', { get: function() this._parentKey, set: function(v) this._setParentKey(v) }); -Zotero.Utilities.Internal.defineProperty(Zotero.DataObject.prototype, 'parentID', { +Zotero.defineProperty(Zotero.DataObject.prototype, 'parentID', { get: function() this._getParentID(), set: function(v) this._setParentID(v) }); diff --git a/chrome/content/zotero/xpcom/data/libraries.js b/chrome/content/zotero/xpcom/data/libraries.js index 8234f2083..828e35af7 100644 --- a/chrome/content/zotero/xpcom/data/libraries.js +++ b/chrome/content/zotero/xpcom/data/libraries.js @@ -28,7 +28,7 @@ Zotero.Libraries = new function () { _userLibraryID, _libraryDataLoaded = false; - Zotero.Utilities.Internal.defineProperty(this, 'userLibraryID', { + Zotero.defineProperty(this, 'userLibraryID', { get: function() { if (!_libraryDataLoaded) { throw new Error("Library data not yet loaded"); diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index f88c08f75..bbe1767c0 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -493,24 +493,6 @@ Zotero.Utilities.Internal = { }, 0, 0, null); return pipe.inputStream; - }, - - /** - * 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 - */ - "defineProperty": function(obj, prop, desc) { - if (typeof prop != 'string') throw new Error("Property must be a string"); - var d = { __proto__: null, enumerable: true }; // Enumerable by default - for (let p in desc) { - if (!desc.hasOwnProperty(p)) continue; - d[p] = desc[p]; - } - Object.defineProperty(obj, prop, d); } } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index cdd4bd080..0db278232 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1400,6 +1400,24 @@ 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 + */ + this.defineProperty = function(obj, prop, desc) { + if (typeof prop != 'string') throw new Error("Property must be a string"); + var d = { __proto__: null, enumerable: true }; // Enumerable by default + for (let p in desc) { + if (!desc.hasOwnProperty(p)) continue; + d[p] = desc[p]; + } + Object.defineProperty(obj, prop, d); + } + /* * This function should be removed *