})
})
+ test('should NOT wrap as function if expression is already function expression (with Typescript)', () => {
+ const { node } = parseWithVOn(`<div @click="(e: any): any => foo(e)"/>`)
+ expect((node.codegenNode as VNodeCall).props).toMatchObject({
+ properties: [
+ {
+ key: { content: `onClick` },
+ value: {
+ type: NodeTypes.SIMPLE_EXPRESSION,
+ content: `(e: any): any => foo(e)`
+ }
+ }
+ ]
+ })
+ })
+
test('should NOT wrap as function if expression is already function expression (with newlines)', () => {
const { node } = parseWithVOn(
`<div @click="
import { TO_HANDLER_KEY } from '../runtimeHelpers'
const fnExpRE =
- /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/
+ /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/
export interface VOnDirectiveNode extends DirectiveNode {
// v-on without arg is handled directly in ./transformElements.ts due to it affecting