From 1e84f2ee6e70810ebe112a91777bd60ff8bdea85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 1 Dec 2016 12:50:06 +0100 Subject: [PATCH] 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. --- src/octoprint/static/js/app/helpers.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index ef4a4d6f..98b6d631 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -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 {