fix(compiler-vapor): add newline after effect body

This commit is contained in:
三咲智子 Kevin Deng 2024-02-08 21:43:05 +08:00
parent 697102f796
commit 126796edb9
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
2 changed files with 10 additions and 7 deletions

View File

@ -340,7 +340,8 @@ export function render(_ctx) {
_renderEffect(() => { _renderEffect(() => {
_on(n1, (_ctx.event) === "click" ? "mouseup" : (_ctx.event), () => _ctx.test, undefined, { _on(n1, (_ctx.event) === "click" ? "mouseup" : (_ctx.event), () => _ctx.test, undefined, {
modifiers: ["middle"] modifiers: ["middle"]
})}) })
})
return n0 return n0
}" }"
`; `;
@ -370,7 +371,8 @@ export function render(_ctx) {
_on(n1, (_ctx.event) === "click" ? "contextmenu" : (_ctx.event), () => _ctx.test, undefined, { _on(n1, (_ctx.event) === "click" ? "contextmenu" : (_ctx.event), () => _ctx.test, undefined, {
modifiers: ["right"], modifiers: ["right"],
keys: ["right"] keys: ["right"]
})}) })
})
return n0 return n0
}" }"
`; `;
@ -398,7 +400,8 @@ export function render(_ctx) {
_on(n1, _ctx.e, () => _ctx.test, undefined, { _on(n1, _ctx.e, () => _ctx.test, undefined, {
modifiers: ["left"], modifiers: ["left"],
keys: ["left"] keys: ["left"]
})}) })
})
return n0 return n0
}" }"
`; `;

View File

@ -76,14 +76,14 @@ export function genEffect({ operations }: IREffect, context: CodegenContext) {
`${vaporHelper('renderEffect')}(() => `, `${vaporHelper('renderEffect')}(() => `,
) )
const [fragOps, pushOps] = buildCodeFragment() const [operationsExps, pushOps] = buildCodeFragment()
operations.forEach(op => pushOps(...genOperation(op, context))) operations.forEach(op => pushOps(...genOperation(op, context)))
const newlineCount = fragOps.filter(frag => frag === NEWLINE).length const newlineCount = operationsExps.filter(frag => frag === NEWLINE).length
if (newlineCount > 1) { if (newlineCount > 1) {
push('{', INDENT_START, ...fragOps, INDENT_END, '})') push('{', INDENT_START, ...operationsExps, INDENT_END, NEWLINE, '})')
} else { } else {
push(...fragOps.filter(frag => frag !== NEWLINE), ')') push(...operationsExps.filter(frag => frag !== NEWLINE), ')')
} }
return frag return frag