diff --git a/js/inject/debug.js b/js/inject/debug.js index e09bbde..54806de 100644 --- a/js/inject/debug.js +++ b/js/inject/debug.js @@ -118,7 +118,7 @@ var inject = function () { applyPerf: {}, scopes: {}, // map of scope.$ids --> scope objects - rootScopes: [], // array of refs to root scopes + rootScopes: {}, // map of $ids --> refs to root scopes deps: [] }; @@ -268,7 +268,6 @@ var inject = function () { return ret; }; } else { - var thatScope = this; watchExpression = function () { var start = window.performance.webkitNow(); var ret = thatScope.$eval(w); @@ -281,7 +280,7 @@ var inject = function () { // patch applyFunction // ------------------- - if (applyFunction) { + if (typeof applyFunction === 'function') { var applyStr = applyFunction.toString(); var unpatchedApplyFunction = applyFunction; applyFunction = function () { @@ -323,13 +322,17 @@ var inject = function () { $delegate.__proto__.$new = function () { var ret = _new.apply(this, arguments); + if (ret.$root) { + debug.rootScopes[ret.$root.$id] = ret.$root; + } + // create empty watchers array for this scope if (!debug.watchers[ret.$id]) { debug.watchers[ret.$id] = []; } return ret; - } + }; // patch apply // ----------- diff --git a/js/services/appContext.js b/js/services/appContext.js index b686121..cabb2ee 100644 --- a/js/services/appContext.js +++ b/js/services/appContext.js @@ -19,7 +19,9 @@ panelApp.factory('appContext', function (chromeExtension) { } }, function (data) { - _debugCache = data; + if (data) { + _debugCache = data; + } _pollListeners.forEach(function (fn) { fn(); }); @@ -30,12 +32,6 @@ panelApp.factory('appContext', function (chromeExtension) { }; getDebugData(); - // Helpers - // ======= - - - - // Public API // ========== return { @@ -83,7 +79,6 @@ panelApp.factory('appContext', function (chromeExtension) { return _debugCache.deps; }, - getAngularVersion: function (cb) { chromeExtension.eval(function () { return window.angular.version.full + @@ -157,7 +152,7 @@ panelApp.factory('appContext', function (chromeExtension) { getDebug: function (cb) { chromeExtension.eval(function (window) { - return document.cookie.indexOf('__ngDebug=true') != -1; + return document.cookie.indexOf('__ngDebug=true') !== -1; }, cb); }, @@ -169,7 +164,7 @@ panelApp.factory('appContext', function (chromeExtension) { '}'); }, - // takes # of miliseconds + // takes # of milliseconds setPollInterval: function (setting) { _pollInterval = setting; },