diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 8f9be5e680fc..83599b19af57 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -864,12 +864,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 656385e9681c..93d0192b51ba 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -1046,6 +1046,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) {