Skip to content

Commit 901cfc9

Browse files
authored
fix: improve ssr template literal generation (#10127)
1 parent cd2263f commit 901cfc9

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

.changeset/wicked-hairs-cheer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: improve ssr template literal generation

packages/svelte/src/compiler/phases/3-transform/server/transform-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ function serialize_attribute_value(
705705
/** @type {import('estree').Expression} */ (context.visit(node.expression))
706706
)
707707
);
708-
if (i === attribute_value.length) {
708+
if (i === attribute_value.length || attribute_value[i]?.type !== 'Text') {
709709
quasis.push(b.quasi('', true));
710710
}
711711
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
html: `<div class="123"></div><img src="12 hello, world 13">`
6+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
let a = 1;
3+
let b = 2;
4+
let c = 3;
5+
</script>
6+
7+
<div class="{a}{b}{c}" />
8+
9+
<img src="{a}{b} hello, world {a}{c}" />

0 commit comments

Comments
 (0)