From fce0052322a96fe6b566cf1c8bed1ab217ae5af1 Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Sun, 21 Dec 2014 19:14:20 -0800 Subject: [PATCH] fix(inspectedApp): handle refresh better --- .../components/inspected-app/inspected-app.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/panel/components/inspected-app/inspected-app.js b/panel/components/inspected-app/inspected-app.js index baf1e44..1f752ce 100644 --- a/panel/components/inspected-app/inspected-app.js +++ b/panel/components/inspected-app/inspected-app.js @@ -80,11 +80,17 @@ function inspectedAppService($rootScope, $q) { if (hint.event === 'scope:new') { addNewScope(hint); } else if (hint.id && scopes[hint.id]) { - if (hint.event === 'model:change') { - scopes[hint.id].models[hint.path] = (typeof hint.value === 'undefined') ? + var scope = scopes[hint.id]; + if (hint.event === 'scope:destroy') { + if (scope.parent) { + scope.parent.children.splice(scope.parent.children.indexOf(child), 1); + } + delete scopes[hint.id]; + } else if (hint.event === 'model:change') { + scope.models[hint.path] = (typeof hint.value === 'undefined') ? undefined : JSON.parse(hint.value); } else if (hint.event === 'scope:link') { - scopes[hint.id].descriptor = hint.descriptor; + scope.descriptor = hint.descriptor; } } $rootScope.$broadcast(hint.event, hint); @@ -92,6 +98,7 @@ function inspectedAppService($rootScope, $q) { } function onRefreshMessage() { + clear(scopes); hints.length = 0; } @@ -106,4 +113,10 @@ function inspectedAppService($rootScope, $q) { } } + function clear (obj) { + Object.keys(obj).forEach(function (key) { + delete obj[key]; + }); + } + }