fix: improve text node output (#10081)

* fix: improve text node output

* revert
pull/10087/head
Dominic Gannaway 1 year ago committed by GitHub
parent e9b0908ed8
commit 94aab90bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: improve text node output

@ -1531,6 +1531,7 @@ function process_children(nodes, parent, { visit, state }) {
expression = b.call('$.sibling', text_id);
}
let is_fragment = false;
for (let i = 0; i < nodes.length; i += 1) {
const node = nodes[i];
@ -1538,7 +1539,12 @@ function process_children(nodes, parent, { visit, state }) {
sequence.push(node);
} else {
if (sequence.length > 0) {
flush_sequence(sequence, true);
flush_sequence(sequence, is_fragment);
// Ensure we move to the next sibling for the case where we move reference within a fragment
if (!is_fragment && sequence.length === 1 && sequence[0].type === 'ExpressionTag') {
expression = b.call('$.sibling', expression);
is_fragment = true;
}
sequence = [];
}

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: `<p>A<br>B<br>C<br></p>`
});

@ -0,0 +1,9 @@
<script>
let array = $state(['A', 'B', 'C']);
</script>
<p>
{#each array as a}
{a}<br/>
{/each}
</p>
Loading…
Cancel
Save