From 1d7a95df565192fc02a18b0b297b39dd615eaeb5 Mon Sep 17 00:00:00 2001 From: Daniel Luz Date: Sun, 4 Nov 2012 19:11:24 -0200 Subject: feat(scope): only evaluate constant $watch expressions once --- src/ng/rootScope.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index b6a582bc..866b957e 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -300,6 +300,14 @@ function $RootScopeProvider(){ watcher.fn = function(newVal, oldVal, scope) {listenFn(scope);}; } + if (typeof watchExp == 'string' && get.constant) { + var originalFn = watcher.fn; + watcher.fn = function(newVal, oldVal, scope) { + originalFn.call(this, newVal, oldVal, scope); + arrayRemove(array, watcher); + }; + } + if (!array) { array = scope.$$watchers = []; } -- cgit v1.2.3