File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,21 @@ describe('compiler: transform v-on', () => {
271
271
} )
272
272
} )
273
273
274
+ test ( 'should NOT wrap as function if expression is already function expression (with Typescript)' , ( ) => {
275
+ const { node } = parseWithVOn ( `<div @click="(e: any): any => foo(e)"/>` )
276
+ expect ( ( node . codegenNode as VNodeCall ) . props ) . toMatchObject ( {
277
+ properties : [
278
+ {
279
+ key : { content : `onClick` } ,
280
+ value : {
281
+ type : NodeTypes . SIMPLE_EXPRESSION ,
282
+ content : `(e: any): any => foo(e)`
283
+ }
284
+ }
285
+ ]
286
+ } )
287
+ } )
288
+
274
289
test ( 'should NOT wrap as function if expression is already function expression (with newlines)' , ( ) => {
275
290
const { node } = parseWithVOn (
276
291
`<div @click="
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import { hasScopeRef, isMemberExpression } from '../utils'
17
17
import { TO_HANDLER_KEY } from '../runtimeHelpers'
18
18
19
19
const fnExpRE =
20
- / ^ \s * ( [ \w $ _ ] + | ( a s y n c \s * ) ? \( [ ^ ) ] * ?\) ) \s * = > | ^ \s * ( a s y n c \s + ) ? f u n c t i o n (?: \s + [ \w $ ] + ) ? \s * \( /
20
+ / ^ \s * ( [ \w $ _ ] + | ( a s y n c \s * ) ? \( [ ^ ) ] * ?\) ) \s * ( : [ ^ = ] + ) ? = > | ^ \s * ( a s y n c \s + ) ? f u n c t i o n (?: \s + [ \w $ ] + ) ? \s * \( /
21
21
22
22
export interface VOnDirectiveNode extends DirectiveNode {
23
23
// v-on without arg is handled directly in ./transformElements.ts due to it affecting
You can’t perform that action at this time.
0 commit comments