forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix($rootScope): fix potential memory leak when removing scope listeners
Previously the array entry for listeners was set to null but the array size was not trimmed until the event was broadcasted again (see e6966e0). By keeping track of the listener iteration index globally it can be adjusted if a listener removal effects the index. Fixes angular#16135 Closes angular#16293 BREAKING CHANGE: Recursively invoking `$emit` or `$broadcast` with the same event name is no longer supported. This will now throw a `inevt` minErr.
- Loading branch information
Showing
3 changed files
with
172 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@ngdoc error | ||
@name $rootScope:inevt | ||
@fullName Recursive $emit/$broadcast event | ||
@description | ||
|
||
This error occurs when the an event is `$emit`ed or `$broadcast`ed recursively on a scope. | ||
|
||
For example, when an event listener fires the same event being listened to. | ||
|
||
``` | ||
$scope.$on('foo', function() { | ||
$scope.$emit('foo'); | ||
}); | ||
``` | ||
|
||
Or when a parent element causes indirect recursion. | ||
|
||
``` | ||
$scope.$on('foo', function() { | ||
$rootScope.$broadcast('foo'); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters