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

Component with top level each-else appears in wrong place when wrapped in if #2917

Closed
trbrc opened this issue May 31, 2019 · 1 comment · Fixed by #3112
Closed

Component with top level each-else appears in wrong place when wrapped in if #2917

trbrc opened this issue May 31, 2019 · 1 comment · Fixed by #3112
Labels

Comments

@trbrc
Copy link
Contributor

trbrc commented May 31, 2019

This bug appears when a child component has a top level {#each}...{:else}...{/each} loop:

{#each list as item, index}
	<p>Item {index} is "{item}"</p>
{:else}
	<p>No items!</p>
{/each}

and it's rendered inside an {#if}{/if} in the parent:

{#if showList}
	<Child list={[]}/>
{/if}
This should come after the list

Whenever the :else section of the child is triggered, the child will be incorrectly inserted after any supposed next siblings.

See REPL for repro: https://svelte.dev/repl/90911dadba184df481f7d44d7e0c0058?version=3.4.4
Click the button twice to see how the pink text in the second example ends up in the wrong place.

@trbrc trbrc changed the title Component top level each-else in wrong place when wrapped in if Component with top level each-else appears in wrong place when wrapped in if May 31, 2019
@Conduitry Conduitry added the bug label Jun 21, 2019
Rich-Harris added a commit that referenced this issue Jun 25, 2019
Rich-Harris added a commit that referenced this issue Jun 27, 2019
fix placement of each-else block, and clarify node references in source
@Rich-Harris
Copy link
Member

Thanks, this is fixed in 3.6.2

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

Successfully merging a pull request may close this issue.

3 participants