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 doesn't get removed in #each with no props/children #3035

Closed
jamesbirtles opened this issue Jun 17, 2019 · 5 comments · Fixed by #3106
Closed

Component doesn't get removed in #each with no props/children #3035

jamesbirtles opened this issue Jun 17, 2019 · 5 comments · Fixed by #3106
Labels

Comments

@jamesbirtles
Copy link
Contributor

Repro: https://svelte.dev/repl/8d5bc96db7634fe0b898b6755b0e7b90?version=3.5.1

Hit the add button, works. Hit the remove button, it fails!

If you add any property to MyComp or give it children, then the remove button begins to work.

@Conduitry Conduitry added the bug label Jun 17, 2019
@usernamus
Copy link

You must use unique keys on list items so that Svelte knows which item to delete. Please, read this part of documentation for a better understanding: Svelte:each

Fix your code, show in 15 line: REPL

@usernamus
Copy link

@UnwrittenFun, not sure about the completeness of my previous comment. But this may be the solution

@Panya
Copy link
Contributor

Panya commented Jun 19, 2019

This case is broken in 3.5.2 even with unique keys (REPL). Try to click on the remove button.

@Rich-Harris
Copy link
Member

The original issue is a bug — without a specified key, it should behave as though you'd done this:

{#each arr as item, i (i)}
	<MyComp />
{/each}

The keyed case is fixed in 3.5.3.

Rich-Harris added a commit that referenced this issue Jun 25, 2019
Rich-Harris added a commit that referenced this issue Jun 25, 2019
remove components without props from each block
@Rich-Harris
Copy link
Member

No idea how this bug survived in the wild so long. Fixed in 3.6.0

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.

5 participants