await foo($event)"/>`)
+ expect((node.codegenNode as VNodeCall).props).toMatchObject({
+ properties: [
+ {
+ key: { content: `onClick` },
+ value: {
+ type: NodeTypes.SIMPLE_EXPRESSION,
+ content: `async $event => await foo($event)`
+ }
+ }
+ ]
+ })
+ })
+
test('should NOT wrap as function if expression is already function expression (with newlines)', () => {
const { node } = parseWithVOn(
`
{
})
})
+ test('inline async arrow function with no bracket expression handler', () => {
+ const { root, node } = parseWithVOn(
+ `
`,
+ {
+ prefixIdentifiers: true,
+ cacheHandlers: true
+ }
+ )
+
+ expect(root.cached).toBe(1)
+ const vnodeCall = node.codegenNode as VNodeCall
+ // should not treat cached handler as dynamicProp, so no flags
+ expect(vnodeCall.patchFlag).toBeUndefined()
+ expect(
+ (vnodeCall.props as ObjectExpression).properties[0].value
+ ).toMatchObject({
+ type: NodeTypes.JS_CACHE_EXPRESSION,
+ index: 0,
+ value: {
+ type: NodeTypes.COMPOUND_EXPRESSION,
+ children: [
+ `async `,
+ { content: `e` },
+ ` => await `,
+ { content: `_ctx.foo` },
+ `(`,
+ { content: `e` },
+ `)`
+ ]
+ }
+ })
+ })
+
test('inline async function expression handler', () => {
const { root, node } = parseWithVOn(
`
`,