fix: create fewer deriveds for concatenated strings (#15041)

* fix: create fewer deriveds for concatenated strings

* stringified_text -> expression
pull/15021/head
Rich Harris 8 months ago committed by GitHub
parent 2aefc5430d
commit 509ba568f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: create fewer deriveds for concatenated strings

@ -47,8 +47,8 @@ export function build_template_chunk(values, visit, state) {
quasi.value.cooked += node.expression.value + ''; quasi.value.cooked += node.expression.value + '';
} }
} else { } else {
if (contains_multiple_call_expression) { if (node.metadata.expression.has_call && contains_multiple_call_expression) {
const id = b.id(state.scope.generate('stringified_text')); const id = b.id(state.scope.generate('expression'));
state.init.push( state.init.push(
b.const( b.const(
id, id,

@ -16,11 +16,11 @@ export default function Text_nodes_deriveds($$anchor) {
} }
var p = root(); var p = root();
const stringified_text = $.derived(() => text1() ?? ''); const expression = $.derived(() => text1() ?? '');
const stringified_text_1 = $.derived(() => text2() ?? ''); const expression_1 = $.derived(() => text2() ?? '');
var text = $.child(p); var text = $.child(p);
$.template_effect(() => $.set_text(text, `${$.get(stringified_text)}${$.get(stringified_text_1)}`)); $.template_effect(() => $.set_text(text, `${$.get(expression)}${$.get(expression_1)}`));
$.reset(p); $.reset(p);
$.append($$anchor, p); $.append($$anchor, p);
} }
Loading…
Cancel
Save