Don't clear item type set in constructor when loading primary data
Generally, don't clear the change state for primaryData when calling loadPrimaryData() on an item that doesn't exist. Specifically, this fixes an issue where calling loadPrimaryData() on a nonexistent item after setting a libraryID and key would also clear any item type set in the constructor. The same would apply for props set in the Collection/Search constructors.
This commit is contained in:
parent
8026f744c5
commit
92ba393488
2 changed files with 10 additions and 2 deletions
|
@ -639,7 +639,6 @@ Zotero.DataObject.prototype.loadPrimaryData = Zotero.Promise.coroutine(function*
|
|||
throw new Error(this._ObjectType + " " + (id ? id : libraryID + "/" + key)
|
||||
+ " not found in Zotero." + this._ObjectType + ".loadPrimaryData()");
|
||||
}
|
||||
this._clearChanged('primaryData');
|
||||
|
||||
// If object doesn't exist, mark all data types as loaded
|
||||
this._markAllDataTypeLoadStates(true);
|
||||
|
|
|
@ -210,7 +210,16 @@ describe("Zotero.DataObject", function() {
|
|||
yield obj.loadPrimaryData();
|
||||
assert.equal(obj.version, objs[type].version);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it("shouldn't overwrite item type set in constructor", async function () {
|
||||
var item = new Zotero.Item('book');
|
||||
item.libraryID = Zotero.Libraries.userLibraryID;
|
||||
item.key = Zotero.DataObjectUtilities.generateKey();
|
||||
await item.loadPrimaryData();
|
||||
var saved = await item.saveTx();
|
||||
assert.ok(saved);
|
||||
});
|
||||
})
|
||||
|
||||
describe("#loadAllData()", function () {
|
||||
|
|
Loading…
Reference in a new issue