Skip to content

fix: whitespace completely removed in each loop #11937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wise-lemons-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: whitespace completely removed in each loop
6 changes: 5 additions & 1 deletion packages/svelte/src/internal/client/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ export function set_should_intro(value) {
* @returns {void}
*/
export function set_text(dom, value) {
// __nodeValue is ' ' by default...this means that if we are trying to set the value of a node
// that has never been updated but is already ' ' that node will never be set and it will remain
// an empty text node.

// @ts-expect-error need to add __value to patched prototype
const prev_node_value = dom.__nodeValue;
const prev_node_value = dom.nodeValue === dom.__nodeValue ? dom.__nodeValue : dom.nodeValue;
const next_node_value = stringify(value);
if (hydrating && dom.nodeValue === next_node_value) {
// In case of hydration don't reset the nodeValue as it's already correct.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { flushSync } from 'svelte';
import { test } from '../../test';

export default test({
html: `<p>space between</p>`
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<svelte:options runes />

<p>
{#each ['space', ' ', 'between'] as word}
{word}
{/each}
</p>
Loading