Store copy of changed object in _markFieldChange()

Otherwise a splice() on a stored array affects the calculation of what's
new.
This commit is contained in:
Dan Stillman 2015-06-01 19:58:01 -04:00
parent 5fc524bcb2
commit b59fa1eed9

View File

@ -556,10 +556,16 @@ Zotero.DataObject.prototype._markAllDataTypeLoadStates = function (loaded) {
*/
Zotero.DataObject.prototype._markFieldChange = function (field, oldValue) {
// Only save if object already exists and field not already changed
if (!this.id || typeof this._previousData[field] != 'undefined') {
if (!this.id || this._previousData[field] !== undefined) {
return;
}
this._previousData[field] = oldValue;
if (Array.isArray(oldValue)) {
this._previousData[field] = [];
Object.assign(this._previousData[field], oldValue)
}
else {
this._previousData[field] = oldValue;
}
}
/**