Skip to content

Commit 9facca5

Browse files
committed
events: fix propagation - should propagate when there are no callbacks on current instance
1 parent 9f6f9dc commit 9facca5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/api/events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ exports.$off = function (event, fn) {
8787
*/
8888

8989
exports.$emit = function (event) {
90-
this._shouldPropagate = false
9190
var cbs = this._events[event]
91+
this._shouldPropagate = !cbs
9292
if (cbs) {
9393
cbs = cbs.length > 1
9494
? _.toArray(cbs)

test/unit/specs/api/events_spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,13 @@ describe('Events API', function () {
143143
it('$dispatch with propagation', function () {
144144
var child = vm.$addChild()
145145
var child2 = child.$addChild()
146+
var child3 = child2.$addChild()
146147
child.$on('test', function () {
147148
spy()
148149
return true
149150
})
150151
vm.$on('test', spy)
151-
child2.$dispatch('test')
152+
child3.$dispatch('test')
152153
expect(spy.calls.count()).toBe(2)
153154
})
154155

0 commit comments

Comments
 (0)