@@ -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 (async)' , ( ) => {
275
+ const { node } = parseWithVOn ( `<div @click="async $event => await foo($event)"/>` )
276
+ expect ( ( node . codegenNode as VNodeCall ) . props ) . toMatchObject ( {
277
+ properties : [
278
+ {
279
+ key : { content : `onClick` } ,
280
+ value : {
281
+ type : NodeTypes . SIMPLE_EXPRESSION ,
282
+ content : `async $event => await foo($event)`
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="
@@ -613,6 +628,39 @@ describe('compiler: transform v-on', () => {
613
628
} )
614
629
} )
615
630
631
+ test ( 'inline async arrow function with no bracket expression handler' , ( ) => {
632
+ const { root, node } = parseWithVOn (
633
+ `<div v-on:click="async e => await foo(e)" />` ,
634
+ {
635
+ prefixIdentifiers : true ,
636
+ cacheHandlers : true
637
+ }
638
+ )
639
+
640
+ expect ( root . cached ) . toBe ( 1 )
641
+ const vnodeCall = node . codegenNode as VNodeCall
642
+ // should not treat cached handler as dynamicProp, so no flags
643
+ expect ( vnodeCall . patchFlag ) . toBeUndefined ( )
644
+ expect (
645
+ ( vnodeCall . props as ObjectExpression ) . properties [ 0 ] . value
646
+ ) . toMatchObject ( {
647
+ type : NodeTypes . JS_CACHE_EXPRESSION ,
648
+ index : 0 ,
649
+ value : {
650
+ type : NodeTypes . COMPOUND_EXPRESSION ,
651
+ children : [
652
+ `async ` ,
653
+ { content : `e` } ,
654
+ ` => await ` ,
655
+ { content : `_ctx.foo` } ,
656
+ `(` ,
657
+ { content : `e` } ,
658
+ `)`
659
+ ]
660
+ }
661
+ } )
662
+ } )
663
+
616
664
test ( 'inline async function expression handler' , ( ) => {
617
665
const { root, node } = parseWithVOn (
618
666
`<div v-on:click="async function () { await foo() } " />` ,
0 commit comments