Browse Source

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

dev
Mattia Trapani 4 years ago
committed by GitHub
parent
commit
c6d7a6fce7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/core/instance/render-helpers/check-keycodes.js
  2. 11
      test/unit/features/directives/on.spec.js

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

@ -31,4 +31,5 @@ export function checkKeyCodes (
} else if (eventKeyName) { } else if (eventKeyName) {
return hyphenate(eventKeyName) !== key return hyphenate(eventKeyName) !== key
} }
return eventKeyCode === undefined
} }

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

@ -976,6 +976,17 @@ describe('Directive v-on', () => {
expect(value).toBe(1) 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', () => { describe('dynamic arguments', () => {
it('basic', done => { it('basic', done => {
const spy = jasmine.createSpy() const spy = jasmine.createSpy()

Loading…
Cancel
Save