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:
Gina Häußge 2016-12-01 12:50:06 +01:00
parent 4541148aa5
commit 1e84f2ee6e

View file

@ -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 {