This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -867,12 +867,14 @@ function $RootScopeProvider(){
867
867
continue ;
868
868
}
869
869
try {
870
+ //allow all listeners attached to the current scope to run
870
871
namedListeners [ i ] . apply ( null , listenerArgs ) ;
871
- if ( stopPropagation ) return event ;
872
872
} catch ( e ) {
873
873
$exceptionHandler ( e ) ;
874
874
}
875
875
}
876
+ //if any listener on the current scope stops propagation, prevent bubbling
877
+ if ( stopPropagation ) return event ;
876
878
//traverse upwards
877
879
scope = scope . $parent ;
878
880
} while ( scope ) ;
Original file line number Diff line number Diff line change @@ -1060,6 +1060,14 @@ describe('Scope', function() {
1060
1060
expect ( log ) . toEqual ( '2>1>0>' ) ;
1061
1061
} ) ;
1062
1062
1063
+ it ( 'should allow all events on the same scope to run even if stopPropagation is called' , function ( ) {
1064
+ child . $on ( 'myEvent' , logger ) ;
1065
+ grandChild . $on ( 'myEvent' , function ( e ) { e . stopPropagation ( ) ; } ) ;
1066
+ grandChild . $on ( 'myEvent' , logger ) ;
1067
+ grandChild . $on ( 'myEvent' , logger ) ;
1068
+ grandChild . $emit ( 'myEvent' ) ;
1069
+ expect ( log ) . toEqual ( '2>2>2>' ) ;
1070
+ } ) ;
1063
1071
1064
1072
it ( 'should dispatch exceptions to the $exceptionHandler' ,
1065
1073
inject ( function ( $exceptionHandler ) {
You can’t perform that action at this time.
0 commit comments