diff options
| author | Igor Minar | 2012-03-16 09:41:00 -0700 | 
|---|---|---|
| committer | Igor Minar | 2012-03-16 09:41:05 -0700 | 
| commit | 9b1aff905b638aa274a5fc8f88662df446d374bd (patch) | |
| tree | 481bc31495091a99fd187ef8e23b14e8441d7b28 /src/service/scope.js | |
| parent | 252d4548f981e18f496877f0f1a30a6c05c8600f (diff) | |
| download | angular.js-9b1aff905b638aa274a5fc8f88662df446d374bd.tar.bz2 | |
feat(scope): broadcast $destroy event on scope destruction
perf testing shows that in chrome this change adds 5-15% overhead
when destroying 10k nested scopes where each scope has a $destroy listener
Diffstat (limited to 'src/service/scope.js')
| -rw-r--r-- | src/service/scope.js | 3 | 
1 files changed, 2 insertions, 1 deletions
diff --git a/src/service/scope.js b/src/service/scope.js index ef1b7b93..b7ee61d6 100644 --- a/src/service/scope.js +++ b/src/service/scope.js @@ -136,7 +136,6 @@ function $RootScopeProvider(){        this.$$phase = this.$parent = this.$$watchers =                       this.$$nextSibling = this.$$prevSibling =                       this.$$childHead = this.$$childTail = null; -      this.$destructor = noop;        this['this'] = this.$root =  this;        this.$$asyncQueue = [];        this.$$listeners = {}; @@ -458,6 +457,8 @@ function $RootScopeProvider(){          if (this.$root == this) return; // we can't remove the root node;          var parent = this.$parent; +        this.$broadcast('$destroy'); +          if (parent.$$childHead == this) parent.$$childHead = this.$$nextSibling;          if (parent.$$childTail == this) parent.$$childTail = this.$$prevSibling;          if (this.$$prevSibling) this.$$prevSibling.$$nextSibling = this.$$nextSibling;  | 
