Skip to content

Commit f388568

Browse files
committed
tweak
1 parent 2961124 commit f388568

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/IfBlock.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export function IfBlock(node, context) {
2121

2222
if (node.alternate) {
2323
const alternate = /** @type {BlockStatement} */ (context.visit(node.alternate));
24-
alternate_id = context.state.scope.generate('alternate');
25-
statements.push(b.var(b.id(alternate_id), b.arrow([b.id('$$anchor')], alternate)));
24+
alternate_id = b.id(context.state.scope.generate('alternate'));
25+
statements.push(b.var(alternate_id, b.arrow([b.id('$$anchor')], alternate)));
2626
}
2727

2828
const { has_await } = node.metadata.expression;
@@ -38,15 +38,8 @@ export function IfBlock(node, context) {
3838
b.if(
3939
test,
4040
b.stmt(b.call(b.id('$$render'), b.id(consequent_id))),
41-
alternate_id
42-
? b.stmt(
43-
b.call(
44-
b.id('$$render'),
45-
b.id(alternate_id),
46-
node.alternate ? b.literal(false) : undefined
47-
)
48-
)
49-
: undefined
41+
alternate_id &&
42+
b.stmt(b.call('$$render', alternate_id, node.alternate && b.literal(false)))
5043
)
5144
])
5245
)

packages/svelte/src/compiler/utils/builders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function labeled(name, body) {
101101

102102
/**
103103
* @param {string | ESTree.Expression} callee
104-
* @param {...(ESTree.Expression | ESTree.SpreadElement | false | undefined)} args
104+
* @param {...(ESTree.Expression | ESTree.SpreadElement | false | undefined | null)} args
105105
* @returns {ESTree.CallExpression}
106106
*/
107107
export function call(callee, ...args) {

0 commit comments

Comments
 (0)