Skip to content

Commit

Permalink
fix(events): properly $off array of events (#6949)
Browse files Browse the repository at this point in the history
  • Loading branch information
madskonradsen authored and yyx990803 committed Nov 2, 2017
1 parent f2e00f7 commit c24f3e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/instance/events.js
Expand Up @@ -92,7 +92,7 @@ export function eventsMixin (Vue: Class<Component>) {
if (!cbs) {
return vm
}
if (arguments.length === 1) {
if (!fn) {
vm._events[event] = null
return vm
}
Expand Down
7 changes: 7 additions & 0 deletions test/unit/features/instance/methods-events.spec.js
Expand Up @@ -41,6 +41,13 @@ describe('Instance methods events', () => {
expect(spy.calls.count()).toBe(1)
})

it('$off multi event without callback', () => {
vm.$on(['test1', 'test2'], spy)
vm.$off(['test1', 'test2'])
vm.$emit('test1')
expect(spy).not.toHaveBeenCalled()
})

it('$once', () => {
vm.$once('test', spy)
vm.$emit('test', 1, 2, 3)
Expand Down

0 comments on commit c24f3e4

Please sign in to comment.