Fix handling of new structures in getOnlyChangedData
Not testing if oldRoot was actually set and contained the key in question could cause issues if a completely new data structure was sent to the backend that was not mirrored by the default settings. Things like e.g. complex configuration items in a by default empty object.
This commit is contained in:
parent
4541148aa5
commit
1e84f2ee6e
1 changed files with 7 additions and 2 deletions
|
|
@ -777,9 +777,14 @@ function getOnlyChangedData(data, oldData) {
|
|||
|
||||
var retval = {};
|
||||
_.forOwn(root, function(value, key) {
|
||||
var oldValue = oldRoot[key];
|
||||
var oldValue = undefined;
|
||||
if (oldRoot != undefined && oldRoot.hasOwnProperty(key)) {
|
||||
oldValue = oldRoot[key];
|
||||
}
|
||||
if (_.isPlainObject(value)) {
|
||||
if (hasDataChanged(value, oldValue)) {
|
||||
if (oldValue == undefined) {
|
||||
retval[key] = value;
|
||||
} else if (hasDataChanged(value, oldValue)) {
|
||||
retval[key] = f(value, oldValue);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue