diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index d94a621d94c6..eba29afa7753 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -836,12 +836,14 @@ function $RootScopeProvider(){ continue; } try { + //allow all listeners attached to the current scope to run namedListeners[i].apply(null, listenerArgs); - if (stopPropagation) return event; } catch (e) { $exceptionHandler(e); } } + //if any listener on the current scope stops propagation, prevent bubbling + if (stopPropagation) return event; //traverse upwards scope = scope.$parent; } while (scope); diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index ddd830881d9b..a64c35e024d8 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -922,6 +922,14 @@ describe('Scope', function() { expect(log).toEqual('2>1>0>'); }); + it('should allow all events on the same scope to run even if stopPropagation is called', function(){ + child.$on('myEvent', logger); + grandChild.$on('myEvent', function(e) { e.stopPropagation(); }); + grandChild.$on('myEvent', logger); + grandChild.$on('myEvent', logger); + grandChild.$emit('myEvent'); + expect(log).toEqual('2>2>2>'); + }); it('should dispatch exceptions to the $exceptionHandler', inject(function($exceptionHandler) {