Move defineProperty from ZU.Internal to Zotero
This commit is contained in:
parent
aca15c0d2d
commit
d4bd0ee811
4 changed files with 23 additions and 23 deletions
|
@ -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)
|
||||
});
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue