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

Keyed {#each} block's {:else} statement is rendering when it shouldn't #4549

Closed
PersonThing opened this issue Mar 12, 2020 · 3 comments · Fixed by #4558
Closed

Keyed {#each} block's {:else} statement is rendering when it shouldn't #4549

PersonThing opened this issue Mar 12, 2020 · 3 comments · Fixed by #4558

Comments

@PersonThing
Copy link

PersonThing commented Mar 12, 2020

Describe the bug
Keyed {#each} block's {:else} statement is rendering when it shouldn't (if the array was empty initially).
Keyed {#each} block's {:else} statement is not rendering when it should (if the array had values initially).

To Reproduce
Click the first toggle - placeholder always shows.
Click the second toggle - placeholder never shows.
If you remove the key on each, behaves as expected, but not a solution.
https://svelte.dev/repl/fa1e979afd1a4928ac45e84fe48574c1?version=3.19.2

Information about your Svelte project:
Chrome 80
Windows 10
Svelte 3.19.2
Webpack, but REPL does it too

Severity
Minor - can just use separate {#if} outside the {#each}

@Conduitry
Copy link
Member

This can probably be combined with #4536.

@PersonThing
Copy link
Author

This can probably be combined with #4536.

Agreed - after noticing that one, I played with it more and found that whether it renders the :else depends entirely on whether the array was populated initially or not. It will always render if array had no value to start, and will never render if array had a value to start.

Better REPL:
https://svelte.dev/repl/fa1e979afd1a4928ac45e84fe48574c1?version=3.19.2

@Conduitry
Copy link
Member

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