diff options
| author | Igor Minar | 2012-11-30 01:16:08 +0100 | 
|---|---|---|
| committer | Igor Minar | 2012-11-30 13:09:50 +0100 | 
| commit | e7ba83069117b4ed6ebf383c30c73224632d569a (patch) | |
| tree | 9f7cce95d92c04e0be773cdc9d9b148dbf78e2c4 /src/ng | |
| parent | 4eb0716711e616949e8f45ef71b166989246eb9c (diff) | |
| download | angular.js-e7ba83069117b4ed6ebf383c30c73224632d569a.tar.bz2 | |
fix(Scope): ensure that a scope is destroyed only once
Due to bd524fc4 calling $destroy() on a scope mupltiple times cases NPE.
Closes #1627
Diffstat (limited to 'src/ng')
| -rw-r--r-- | src/ng/rootScope.js | 5 | 
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 04b5c878..6ec18079 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -134,6 +134,7 @@ function $RootScopeProvider(){                       this.$$nextSibling = this.$$prevSibling =                       this.$$childHead = this.$$childTail = null;        this['this'] = this.$root =  this; +      this.$$destroyed = false;        this.$$asyncQueue = [];        this.$$listeners = {};      } @@ -467,10 +468,12 @@ function $RootScopeProvider(){         * perform any necessary cleanup.         */        $destroy: function() { -        if ($rootScope == this) return; // we can't remove the root node; +        // we can't destroy the root scope or a scope that has been already destroyed +        if ($rootScope == this || this.$$destroyed) return;          var parent = this.$parent;          this.$broadcast('$destroy'); +        this.$$destroyed = true;          if (parent.$$childHead == this) parent.$$childHead = this.$$nextSibling;          if (parent.$$childTail == this) parent.$$childTail = this.$$prevSibling;  | 
