@@ -286,6 +286,23 @@ describe('compiler: transform v-on', () => {
286286 } )
287287 } )
288288
289+ test ( 'should NOT wrap as function if expression is already function expression (async)' , ( ) => {
290+ const { node } = parseWithVOn (
291+ `<div @click="async $event => await foo($event)"/>` ,
292+ )
293+ expect ( ( node . codegenNode as VNodeCall ) . props ) . toMatchObject ( {
294+ properties : [
295+ {
296+ key : { content : `onClick` } ,
297+ value : {
298+ type : NodeTypes . SIMPLE_EXPRESSION ,
299+ content : `async $event => await foo($event)` ,
300+ } ,
301+ } ,
302+ ] ,
303+ } )
304+ } )
305+
289306 test ( 'should NOT wrap as function if expression is already function expression (with newlines)' , ( ) => {
290307 const { node } = parseWithVOn (
291308 `<div @click="
@@ -630,6 +647,39 @@ describe('compiler: transform v-on', () => {
630647 } )
631648 } )
632649
650+ test ( 'inline async arrow function with no bracket expression handler' , ( ) => {
651+ const { root, node } = parseWithVOn (
652+ `<div v-on:click="async e => await foo(e)" />` ,
653+ {
654+ prefixIdentifiers : true ,
655+ cacheHandlers : true ,
656+ } ,
657+ )
658+
659+ expect ( root . cached ) . toBe ( 1 )
660+ const vnodeCall = node . codegenNode as VNodeCall
661+ // should not treat cached handler as dynamicProp, so no flags
662+ expect ( vnodeCall . patchFlag ) . toBeUndefined ( )
663+ expect (
664+ ( vnodeCall . props as ObjectExpression ) . properties [ 0 ] . value ,
665+ ) . toMatchObject ( {
666+ type : NodeTypes . JS_CACHE_EXPRESSION ,
667+ index : 0 ,
668+ value : {
669+ type : NodeTypes . COMPOUND_EXPRESSION ,
670+ children : [
671+ `async ` ,
672+ { content : `e` } ,
673+ ` => await ` ,
674+ { content : `_ctx.foo` } ,
675+ `(` ,
676+ { content : `e` } ,
677+ `)` ,
678+ ] ,
679+ } ,
680+ } )
681+ } )
682+
633683 test ( 'inline async function expression handler' , ( ) => {
634684 const { root, node } = parseWithVOn (
635685 `<div v-on:click="async function () { await foo() } " />` ,
0 commit comments