key: { content: `onClick` },
value: {
type: NodeTypes.COMPOUND_EXPRESSION,
- children: [`($event, ...args) => (`, { content: `i++` }, `)`]
+ children: [`$event => (`, { content: `i++` }, `)`]
}
}
]
// should wrap with `{` for multiple statements
// in this case the return value is discarded and the behavior is
// consistent with 2.x
- children: [
- `($event, ...args) => {`,
- { content: `foo();bar()` },
- `}`
- ]
+ children: [`$event => {`, { content: `foo();bar()` }, `}`]
}
}
]
})
})
- test('should handle multiple line statement', () => {
+ test('should handle multi-line statement', () => {
const { node } = parseWithVOn(`<div @click="\nfoo();\nbar()\n"/>`)
expect((node.codegenNode as VNodeCall).props).toMatchObject({
properties: [
value: {
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
- `($event, ...args) => (`,
+ `$event => (`,
{
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
value: {
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
- `($event, ...args) => {`,
+ `$event => {`,
{
children: [
{ content: `_ctx.foo` },
value: {
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
- `($event, ...args) => (`,
+ `$event => (`,
{ children: [{ content: `_ctx.foo` }, `++`] },
`)`
]
if (isInlineStatement || (isCacheable && isMemberExp)) {
// wrap inline statement in a function expression
exp = createCompoundExpression([
- `($event, ...args) => ${hasMultipleStatements ? `{` : `(`}`,
+ `${isInlineStatement ? `$event` : `($event, ...args)`} => ${
+ hasMultipleStatements ? `{` : `(`
+ }`,
exp,
hasMultipleStatements ? `}` : `)`
])