-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
$destroy
Prevent isolated scopes from having listeners that get called multiple times when on `$destroy`
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,7 @@ function $RootScopeProvider(){ | |
// ensure that there is just one async queue per $rootScope and its children | ||
child.$$asyncQueue = this.$$asyncQueue; | ||
child.$$postDigestQueue = this.$$postDigestQueue; | ||
child.$on('$destroy', function() { child.$$destroyed = true; }); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lgalfaso
Author
Owner
|
||
} else { | ||
// Only create a child scope class if somebody asks for one, | ||
// but cache it to allow the VM to optimize lookups. | ||
|
It worries me that destroying a parent scope doesn't actually destroy child scope already! I guess this was because before angular#9281 lands, it is likely that transclude scopes are not properly contained by their template's scope and so we have been relying on DOM removal to trigger destruction of most child scopes.
This change means that if a parent scope is destroyed, it is no longer possible to call $destroy on child scopes, which in turn means that we cannot clean up listeners on those scopes.
I angular#9281 lands, we should, instead of this recurse down the scope tree when a scope is destroyed and explicitly call
$destroy
on each descendant.