8000 events: fix propagation - should propagate when there are no callback… · Aphasia-GitHub/vue@b8b87f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b8b87f7

Browse files
committed
events: fix propagation - should propagate when there are no callbacks on current instance
1 parent 0b4ebe5 commit b8b87f7

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
@@ -144,12 +144,13 @@ describe('Events API', function () {
144144
it('$dispatch with propagation', function () {
145145
var child = vm.$addChild()
146146
var child2 = child.$addChild()
147+
var child3 = child2.$addChild()
147148
child.$on('test', function () {
148149
spy()
149150
return true
150151
})
151152
vm.$on('test', spy)
152-
child2.$dispatch('test')
153+
child3.$dispatch('test')
153154
expect(spy.calls.count()).toBe(2)
154155
})
155156

0 commit comments

Comments
 (0)
0