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 @@ -836,12 +836,14 @@ function $RootScopeProvider(){
836
836
continue ;
837
837
}
838
838
try {
839
+ //allow all listeners attached to the current scope to run
839
840
namedListeners [ i ] . apply ( null , listenerArgs ) ;
840
- if ( stopPropagation ) return event ;
841
841
} catch ( e ) {
842
842
$exceptionHandler ( e ) ;
843
843
}
844
844
}
845
+ //if any listener on the current scope stops propagation, prevent bubbling
846
+ if ( stopPropagation ) return event ;
845
847
//traverse upwards
846
848
scope = scope . $parent ;
847
849
} while ( scope ) ;
Original file line number Diff line number Diff line change @@ -922,6 +922,14 @@ describe('Scope', function() {
922
922
expect ( log ) . toEqual ( '2>1>0>' ) ;
923
923
} ) ;
924
924
925
+ it ( 'should allow all events on the same scope to run even if stopPropagation is called' , function ( ) {
926
+ child . $on ( 'myEvent' , logger ) ;
927
+ grandChild . $on ( 'myEvent' , function ( e ) { e . stopPropagation ( ) ; } ) ;
928
+ grandChild . $on ( 'myEvent' , logger ) ;
929
+ grandChild . $on ( 'myEvent' , logger ) ;
930
+ grandChild . $emit ( 'myEvent' ) ;
931
+ expect ( log ) . toEqual ( '2>2>2>' ) ;
932
+ } ) ;
925
933
926
934
it ( 'should dispatch exceptions to the $exceptionHandler' ,
927
935
inject ( function ( $exceptionHandler ) {
You can’t perform that action at this time.
0 commit comments