Skip to content

Commit e5c9f6c

Browse files
trueadmRich-Harris
andauthored
Update packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js
Co-authored-by: Rich Harris <[email protected]>
1 parent ae0f8dc commit e5c9f6c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,12 @@ export function RegularElement(node, context) {
353353

354354
// special case — if an element that only contains text, we don't need
355355
// to descend into it if the text is non-reactive
356-
const states_and_calls =
356+
// in the rare case that we have static text that can't be inlined
357+
// (e.g. `<span>{location}</span>`), set `textContent` programmatically
358+
const use_text_content =
357359
trimmed.every((node) => node.type === 'Text' || node.type === 'ExpressionTag') &&
358-
trimmed.some((node) => node.type === 'ExpressionTag') &&
359-
get_states_and_calls(trimmed);
360+
trimmed.every((node) => node.type === 'Text' || !node.metadata.expression.has_state) &&
361+
trimmed.some((node) => node.type === 'ExpressionTag');
360362

361363
if (states_and_calls && states_and_calls.states === 0) {
362364
child_state.init.push(

0 commit comments

Comments
 (0)