@@ -563,6 +563,58 @@ describe('compiler: transform v-on', () => {
563
563
} )
564
564
} )
565
565
566
+ test ( 'inline async arrow function expression handler' , ( ) => {
567
+ const { root, node } = parseWithVOn (
568
+ `<div v-on:click="async () => await foo()" />` ,
569
+ {
570
+ prefixIdentifiers : true ,
571
+ cacheHandlers : true
572
+ }
573
+ )
574
+ expect ( root . cached ) . toBe ( 1 )
575
+ const vnodeCall = node . codegenNode as VNodeCall
576
+ // should not treat cached handler as dynamicProp, so no flags
577
+ expect ( vnodeCall . patchFlag ) . toBeUndefined ( )
578
+ expect (
579
+ ( vnodeCall . props as ObjectExpression ) . properties [ 0 ] . value
580
+ ) . toMatchObject ( {
581
+ type : NodeTypes . JS_CACHE_EXPRESSION ,
582
+ index : 0 ,
583
+ value : {
584
+ type : NodeTypes . COMPOUND_EXPRESSION ,
585
+ children : [ `async () => await ` , { content : `_ctx.foo` } , `()` ]
586
+ }
587
+ } )
588
+ } )
589
+
590
+ test ( 'inline async function expression handler' , ( ) => {
591
+ const { root, node } = parseWithVOn (
592
+ `<div v-on:click="async function () { await foo() } " />` ,
593
+ {
594
+ prefixIdentifiers : true ,
595
+ cacheHandlers : true
596
+ }
597
+ )
598
+ expect ( root . cached ) . toBe ( 1 )
599
+ const vnodeCall = node . codegenNode as VNodeCall
600
+ // should not treat cached handler as dynamicProp, so no flags
601
+ expect ( vnodeCall . patchFlag ) . toBeUndefined ( )
602
+ expect (
603
+ ( vnodeCall . props as ObjectExpression ) . properties [ 0 ] . value
604
+ ) . toMatchObject ( {
605
+ type : NodeTypes . JS_CACHE_EXPRESSION ,
606
+ index : 0 ,
607
+ value : {
608
+ type : NodeTypes . COMPOUND_EXPRESSION ,
609
+ children : [
610
+ `async function () { await ` ,
611
+ { content : `_ctx.foo` } ,
612
+ `() } `
613
+ ]
614
+ }
615
+ } )
616
+ } )
617
+
566
618
test ( 'inline statement handler' , ( ) => {
567
619
const { root, node } = parseWithVOn ( `<div v-on:click="foo++" />` , {
568
620
prefixIdentifiers : true ,
0 commit comments