Throw error if non-number is passed to Zotero.DataObjects.getAsync()
Previously, if an id was psased as a string and the id existed in the cache, an error wouldn't be thrown, but if there id wasn't in the cache (e.g., because it was in an unloaded library) it would. This requires an integer in all cases. Note that, among other things, any code that gets ids from object keys will need to convert them to integers before passing to getAsync().
This commit is contained in:
parent
265df6d48c
commit
4e1937680f
1 changed files with 5 additions and 3 deletions
|
@ -172,14 +172,16 @@ Zotero.DataObjects.prototype.getAsync = Zotero.Promise.coroutine(function* (ids,
|
|||
|
||||
for (let i=0; i<ids.length; i++) {
|
||||
let id = ids[i];
|
||||
|
||||
if (!Number.isInteger(id)) {
|
||||
throw new Error(`Invalid ${this._ZDO_object} ID '${id}' (${typeof id})`);
|
||||
}
|
||||
|
||||
// Check if already loaded
|
||||
if (this._objectCache[id]) {
|
||||
toReturn.push(this._objectCache[id]);
|
||||
}
|
||||
else {
|
||||
if (!Number.isInteger(id)) {
|
||||
throw new Error(`Invalid ${this._ZDO_object} ID '${id}' (${typeof id})`);
|
||||
}
|
||||
toLoad.push(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue