Skip to content

Commit c6d7a6f

Browse files
authoredApr 16, 2021
fix(v-on): avoid events with empty keyCode (autocomplete) (#11326)
1 parent ce457f9 commit c6d7a6f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
 

‎src/core/instance/render-helpers/check-keycodes.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ export function checkKeyCodes (
3131
} else if (eventKeyName) {
3232
return hyphenate(eventKeyName) !== key
3333
}
34+
return eventKeyCode === undefined
3435
}

‎test/unit/features/directives/on.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,17 @@ describe('Directive v-on', () => {
976976
expect(value).toBe(1)
977977
})
978978

979+
it('should not execute callback if modifiers are present', () => {
980+
vm = new Vue({
981+
el,
982+
template: '<input @keyup.?="foo">',
983+
methods: { foo: spy }
984+
})
985+
// simulating autocomplete event (Event object with type keyup but without keyCode)
986+
triggerEvent(vm.$el, 'keyup')
987+
expect(spy.calls.count()).toBe(0)
988+
})
989+
979990
describe('dynamic arguments', () => {
980991
it('basic', done => {
981992
const spy = jasmine.createSpy()

0 commit comments

Comments
 (0)
Please sign in to comment.