File tree 1 file changed +5
-3
lines changed 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -1175,6 +1175,7 @@ function $RootScopeProvider() {
1175
1175
$emit : function ( name , args ) {
1176
1176
var empty = [ ] ,
1177
1177
namedListeners ,
1178
+ namedListenersCopy ,
1178
1179
scope = this ,
1179
1180
stopPropagation = false ,
1180
1181
event = {
@@ -1191,19 +1192,20 @@ function $RootScopeProvider() {
1191
1192
1192
1193
do {
1193
1194
namedListeners = scope . $$listeners [ name ] || empty ;
1195
+ namedListenersCopy = namedListeners . slice ( 0 ) ;
1194
1196
event . currentScope = scope ;
1195
1197
for ( i = 0 , length = namedListeners . length ; i < length ; i ++ ) {
1196
1198
1197
1199
// if listeners were deregistered, defragment the array
1198
- if ( ! namedListeners [ i ] ) {
1199
- namedListeners . splice ( i , 1 ) ;
1200
+ if ( namedListeners . indexOf ( namedListenersCopy [ i ] ) === - 1 ) {
1201
+ namedListenersCopy . splice ( i , 1 ) ;
1200
1202
i -- ;
1201
1203
length -- ;
1202
1204
continue ;
1203
1205
}
1204
1206
try {
1205
1207
//allow all listeners attached to the current scope to run
1206
- namedListeners [ i ] . apply ( null , listenerArgs ) ;
1208
+ namedListenersCopy [ i ] . apply ( null , listenerArgs ) ;
1207
1209
} catch ( e ) {
1208
1210
$exceptionHandler ( e ) ;
1209
1211
}
You can’t perform that action at this time.
0 commit comments