Skip to content
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

Trailing whitespace in {#each} removed when block is followed by additional content #2905

Closed
trbrc opened this issue May 30, 2019 · 1 comment

Comments

@trbrc
Copy link
Contributor

trbrc commented May 30, 2019

Example:

{#each ['dog', 'hen', 'fox', 'cat', 'pig', 'ant', 'cow', 'koi'] as value}
  <span>{value} </span>
{/each}

produces a space separated list that visually looks like dog hen fox cat pig ant cow koi. However, if you insert seemingly any content after the each block, such as the following:

{#each ['dog', 'hen', 'fox', 'cat', 'pig', 'ant', 'cow', 'koi'] as value}
  <span>{value} </span>
{/each}
owl

the space disappears and it looks like doghenfoxcatpigantcowkoi owl.

The generated c method changes like this:

		c() {
			span = element("span");
			t0 = text(ctx.value);
-			t1 = space();
		},

REPL: https://svelte.dev/repl/ca1c0968d5d94674b15963ee23d9b64f?version=3.4.4

@Conduitry
Copy link
Member

This sounds the same as long-standing issue #713. I tried briefly looking into it a couple times over the years (!) and each time gave up trying to understand the whitespace handling code in the compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants