File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -118,4 +118,13 @@ describe('runtime-dom: v-on directive', () => {
118
118
expect ( fn ) . toBeCalled ( )
119
119
} )
120
120
} )
121
+
122
+ it ( 'should handle multiple arguments when using modifiers' , ( ) => {
123
+ const el = document . createElement ( 'div' )
124
+ const fn = jest . fn ( )
125
+ const handler = withModifiers ( fn , [ 'ctrl' ] )
126
+ const event = triggerEvent ( el , 'click' , e => ( e . ctrlKey = true ) )
127
+ handler ( event , 'value' , true )
128
+ expect ( fn ) . toBeCalledWith ( event , 'value' , true )
129
+ } )
121
130
} )
Original file line number Diff line number Diff line change @@ -26,12 +26,12 @@ const modifierGuards: Record<
26
26
* @internal
27
27
*/
28
28
export const withModifiers = ( fn : Function , modifiers : string [ ] ) => {
29
- return ( event : Event ) => {
29
+ return ( event : Event , ... args : unknown [ ] ) => {
30
30
for ( let i = 0 ; i < modifiers . length ; i ++ ) {
31
31
const guard = modifierGuards [ modifiers [ i ] ]
32
32
if ( guard && guard ( event , modifiers ) ) return
33
33
}
34
- return fn ( event )
34
+ return fn ( event , ... args )
35
35
}
36
36
}
37
37
You can’t perform that action at this time.
0 commit comments