Skip to content

Commit f6ebff4

Browse files
committed
chore: rebase
1 parent cfe6428 commit f6ebff4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/compiler-vapor/src/generators/component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export function genCreateComponent(
5353
const rawProps = context.withId(() => genRawProps(props, context), ids)
5454
const inlineHandlers: CodeFragment[] = handlers.reduce<CodeFragment[]>(
5555
(acc, { name, value }) => {
56-
const handler = genEventHandler(context, value, false)
56+
// TODO should support .once modifier on component event
57+
const handler = genEventHandler(context, value, undefined,false)
5758
return [...acc, `const ${name} = `, ...handler, NEWLINE]
5859
},
5960
[],

packages/compiler-vapor/src/generators/event.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ export function genEventHandler(
8888
nonKeys: string[]
8989
keys: string[]
9090
} = { nonKeys: [], keys: [] },
91+
needWrap: boolean = true,
9192
): CodeFragment[] {
92-
let handlerExp: CodeFragment[] = [`() => {}`]
93+
let handlerExp: CodeFragment[] = [`{}`]
9394
if (value && value.content.trim()) {
9495
const isMemberExp = isMemberExpression(value, context.options)
9596
const isInlineStatement = !(
@@ -117,7 +118,8 @@ export function genEventHandler(
117118
handlerExp = genWithModifiers(context, handlerExp, nonKeys)
118119
if (keys.length) handlerExp = genWithKeys(context, handlerExp, keys)
119120

120-
return [`() => `, ...handlerExp]
121+
if(needWrap) handlerExp.unshift(`() => `)
122+
return handlerExp
121123
}
122124

123125
function genWithModifiers(

0 commit comments

Comments
 (0)