Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v-on): avoid events with empty keyCode (autocomplete) #11326

Merged
merged 1 commit into from Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/instance/render-helpers/check-keycodes.js
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
Expand Up @@ -962,6 +962,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