diff --git a/packages/runtime-dom/__tests__/directives/vOn.spec.ts b/packages/runtime-dom/__tests__/directives/vOn.spec.ts index 4b9c1471..a08c85af 100644 --- a/packages/runtime-dom/__tests__/directives/vOn.spec.ts +++ b/packages/runtime-dom/__tests__/directives/vOn.spec.ts @@ -118,4 +118,13 @@ describe('runtime-dom: v-on directive', () => { expect(fn).toBeCalled() }) }) + + it('should handle multiple arguments when using modifiers', () => { + const el = document.createElement('div') + const fn = jest.fn() + const handler = withModifiers(fn, ['ctrl']) + const event = triggerEvent(el, 'click', e => (e.ctrlKey = true)) + handler(event, 'value', true) + expect(fn).toBeCalledWith(event, 'value', true) + }) }) diff --git a/packages/runtime-dom/src/directives/vOn.ts b/packages/runtime-dom/src/directives/vOn.ts index 09cc9558..155ee8e2 100644 --- a/packages/runtime-dom/src/directives/vOn.ts +++ b/packages/runtime-dom/src/directives/vOn.ts @@ -26,12 +26,12 @@ const modifierGuards: Record< * @internal */ export const withModifiers = (fn: Function, modifiers: string[]) => { - return (event: Event) => { + return (event: Event, ...args: unknown[]) => { for (let i = 0; i < modifiers.length; i++) { const guard = modifierGuards[modifiers[i]] if (guard && guard(event, modifiers)) return } - return fn(event) + return fn(event, ...args) } }