diff --git a/.changeset/wicked-hairs-cheer.md b/.changeset/wicked-hairs-cheer.md new file mode 100644 index 0000000000..532d81260b --- /dev/null +++ b/.changeset/wicked-hairs-cheer.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: improve ssr template literal generation diff --git a/packages/svelte/src/compiler/phases/3-transform/server/transform-server.js b/packages/svelte/src/compiler/phases/3-transform/server/transform-server.js index f00091a20b..5cb479b91a 100644 --- a/packages/svelte/src/compiler/phases/3-transform/server/transform-server.js +++ b/packages/svelte/src/compiler/phases/3-transform/server/transform-server.js @@ -705,7 +705,7 @@ function serialize_attribute_value( /** @type {import('estree').Expression} */ (context.visit(node.expression)) ) ); - if (i === attribute_value.length) { + if (i === attribute_value.length || attribute_value[i]?.type !== 'Text') { quasis.push(b.quasi('', true)); } } diff --git a/packages/svelte/tests/runtime-runes/samples/attribute-parts/_config.js b/packages/svelte/tests/runtime-runes/samples/attribute-parts/_config.js new file mode 100644 index 0000000000..dabe420686 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/attribute-parts/_config.js @@ -0,0 +1,6 @@ +import { flushSync } from 'svelte'; +import { test } from '../../test'; + +export default test({ + html: `
` +}); diff --git a/packages/svelte/tests/runtime-runes/samples/attribute-parts/main.svelte b/packages/svelte/tests/runtime-runes/samples/attribute-parts/main.svelte new file mode 100644 index 0000000000..3bbd04cb7a --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/attribute-parts/main.svelte @@ -0,0 +1,9 @@ + + + + +