Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit f1baf94

Browse files
committed
wip: save
1 parent a3984a7 commit f1baf94

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

packages/compiler-vapor/__tests__/__snapshots__/compile.spec.ts.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ export function render(_ctx) {
188188
_delegate(n0, "click", () => _ctx.handleClick)
189189
_setInheritAttrs(["id"])
190190
let _count, _count1
191-
_renderEffect(() => _count !== _ctx.count && _setText(n0, (_count = _ctx.count), "foo", _ctx.count, "foo", _ctx.count)
192-
_count1 !== _ctx.count && _setDOMProp(n0, "id", (_count1 = _ctx.count)))
191+
_renderEffect(() => {
192+
_count !== _ctx.count && _setText(n0, (_count = _ctx.count), "foo", _ctx.count, "foo", _ctx.count)
193+
_count1 !== _ctx.count && _setDOMProp(n0, "id", (_count1 = _ctx.count))
194+
})
193195
return n0
194196
}"
195197
`;

packages/compiler-vapor/__tests__/transforms/__snapshots__/transformChildren.spec.ts.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ export function render(_ctx) {
1212
const n1 = _createTextNode(() => [_ctx.second, " ", _ctx.third, " "])
1313
_insert(n1, n4, n3)
1414
let _first, _forth
15-
_renderEffect(() => _first !== _ctx.first && _setText(n0, (_first = _ctx.first))
16-
_forth !== _ctx.forth && _setText(n2, (_forth = _ctx.forth)))
15+
_renderEffect(() => {
16+
_first !== _ctx.first && _setText(n0, (_first = _ctx.first))
17+
_forth !== _ctx.forth && _setText(n2, (_forth = _ctx.forth))
18+
})
1719
return n4
1820
}"
1921
`;

packages/compiler-vapor/__tests__/transforms/__snapshots__/vFor.spec.ts.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ export function render(_ctx) {
5252
const n0 = _createFor(() => (_ctx.items), (_ctx0) => {
5353
const n2 = t0()
5454
_setInheritAttrs(["item", "index"])
55-
_renderEffect(() => _setDynamicProp(n2, "item", _ctx0[0].value)
56-
_setDynamicProp(n2, "index", _ctx0[1].value))
55+
_renderEffect(() => {
56+
_setDynamicProp(n2, "item", _ctx0[0].value)
57+
_setDynamicProp(n2, "index", _ctx0[1].value)
58+
})
5759
return n2
5860
})
5961
return n0

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ export function genEffects(
8181
const { vaporHelper } = context
8282
const [frag, push, unshift] = buildCodeFragment()
8383
const declareNames = new Set<string>()
84+
let operationsCount = 0
8485
for (let i = 0; i < effects.length; i++) {
8586
const effect = (context.processingRenderEffect = effects[i])
87+
operationsCount += effect.operations.length
8688
i > 0 && push(NEWLINE)
8789
push(...genEffect(effect, context, declareNames))
8890
}
8991

9092
const newLineCount = frag.filter(frag => frag === NEWLINE).length
91-
if (newLineCount > 1) {
93+
if (newLineCount > 1 || operationsCount > 1) {
9294
unshift(`{`, INDENT_START, NEWLINE)
9395
push(INDENT_END, NEWLINE, '}')
9496
}

0 commit comments

Comments
 (0)