Skip to content

Commit

Permalink
fix(v-on): avoid events with empty keyCode (autocomplete) (#11326)
Browse files Browse the repository at this point in the history
  • Loading branch information
zupolgec authored Apr 16, 2021
1 parent ce457f9 commit c6d7a6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/instance/render-helpers/check-keycodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ export function checkKeyCodes (
} else if (eventKeyName) {
return hyphenate(eventKeyName) !== key
}
return eventKeyCode === undefined
}
11 changes: 11 additions & 0 deletions test/unit/features/directives/on.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,17 @@ describe('Directive v-on', () => {
expect(value).toBe(1)
})

it('should not execute callback if modifiers are present', () => {
vm = new Vue({
el,
template: '<input @keyup.?="foo">',
methods: { foo: spy }
})
// simulating autocomplete event (Event object with type keyup but without keyCode)
triggerEvent(vm.$el, 'keyup')
expect(spy.calls.count()).toBe(0)
})

describe('dynamic arguments', () => {
it('basic', done => {
const spy = jasmine.createSpy()
Expand Down

0 comments on commit c6d7a6f

Please sign in to comment.