From f11de266f466e9a4be5ccaaed952f1c24b0177ac Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 15 Jul 2019 13:31:01 +0200 Subject: [PATCH] storage.js: Avoid to call JSON.parse with an empty string IE11 seems not to like this.. --- public/js/icinga/storage.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/js/icinga/storage.js b/public/js/icinga/storage.js index b27af9f66..7693a791b 100644 --- a/public/js/icinga/storage.js +++ b/public/js/icinga/storage.js @@ -44,8 +44,17 @@ } if (typeof Icinga.Storage.subscribers[event.key] !== 'undefined') { + var newValue = null, + oldValue = null; + if (event.newValue.length) { + newValue = JSON.parse(event.newValue); + } + if (event.oldValue.length) { + oldValue = JSON.parse(event.oldValue); + } + Icinga.Storage.subscribers[event.key].forEach(function (subscriber) { - subscriber[0].call(subscriber[1], JSON.parse(event.newValue), JSON.parse(event.oldValue), event); + subscriber[0].call(subscriber[1], newValue, oldValue, event); }); } });