diff --git a/src/core/instance/render-helpers/check-keycodes.js b/src/core/instance/render-helpers/check-keycodes.js index c12402b1..02613d4d 100644 --- a/src/core/instance/render-helpers/check-keycodes.js +++ b/src/core/instance/render-helpers/check-keycodes.js @@ -31,4 +31,5 @@ export function checkKeyCodes ( } else if (eventKeyName) { return hyphenate(eventKeyName) !== key } + return eventKeyCode === undefined } diff --git a/test/unit/features/directives/on.spec.js b/test/unit/features/directives/on.spec.js index 95693c19..7c252031 100644 --- a/test/unit/features/directives/on.spec.js +++ b/test/unit/features/directives/on.spec.js @@ -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: '', + 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()