Skip to content

Commit eaa2df5

Browse files
committed
fix
1 parent 1a720ad commit eaa2df5

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function Identifier(node, context) {
8989
// binding and it is outside module scope, the expression cannot
9090
// be inlined (TODO allow inlining in more cases,
9191
// e.g. primitive consts)
92-
let can_inline = !!binding && !binding.scope.parent;
92+
let can_inline = !!binding && !binding.scope.parent && binding.kind === 'normal';
9393

9494
if (binding) {
9595
if (context.state.expression) {

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,24 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
6161
* @param {Sequence} sequence
6262
*/
6363
function flush_sequence(sequence) {
64+
// TODO this should be folded into the `is_inlinable_sequence` block below,
65+
// but it currently causes a test to fail
6466
if (sequence.every((node) => node.type === 'Text')) {
6567
skipped += 1;
6668
state.template.push(sequence.map((node) => node.raw).join(''));
6769
return;
6870
}
6971

70-
state.template.push(' ');
71-
7272
const { has_state, has_call, value } = build_template_literal(sequence, visit, state);
7373

74+
if (is_inlinable_sequence(sequence)) {
75+
skipped += 1;
76+
state.template.push(escape_inline_expression(value));
77+
return;
78+
}
79+
80+
state.template.push(' ');
81+
7482
// if this is a standalone `{expression}`, make sure we handle the case where
7583
// no text node was created because the expression was empty during SSR
7684
const is_text = sequence.length === 1;
@@ -83,13 +91,7 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
8391
} else if (has_state && !within_bound_contenteditable) {
8492
state.update.push(update);
8593
} else {
86-
// if the expression is inlinable we just push it to the template
87-
if (!is_text && is_inlinable_sequence(sequence)) {
88-
state.template.push(escape_inline_expression(value));
89-
} else {
90-
// else we programmatically set the value
91-
state.init.push(b.stmt(b.assignment('=', b.member(id, 'nodeValue'), value)));
92-
}
94+
state.init.push(b.stmt(b.assignment('=', b.member(id, 'nodeValue'), value)));
9395
}
9496
}
9597

0 commit comments

Comments
 (0)