Skip to content

Commit c24f3e4

Browse files
madskonradsenyyx990803
authored andcommitted
fix(events): properly $off array of events (#6949)
1 parent f2e00f7 commit c24f3e4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/core/instance/events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function eventsMixin (Vue: Class<Component>) {
9292
if (!cbs) {
9393
return vm
9494
}
95-
if (arguments.length === 1) {
95+
if (!fn) {
9696
vm._events[event] = null
9797
return vm
9898
}

test/unit/features/instance/methods-events.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ describe('Instance methods events', () => {
4141
expect(spy.calls.count()).toBe(1)
4242
})
4343

44+
it('$off multi event without callback', () => {
45+
vm.$on(['test1', 'test2'], spy)
46+
vm.$off(['test1', 'test2'])
47+
vm.$emit('test1')
48+
expect(spy).not.toHaveBeenCalled()
49+
})
50+
4451
it('$once', () => {
4552
vm.$once('test', spy)
4653
vm.$emit('test', 1, 2, 3)

0 commit comments

Comments
 (0)