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

Destructuring with fallback and then reassigning in {#each} is broken #13822

Closed
wackbyte opened this issue Oct 23, 2024 · 5 comments
Closed

Destructuring with fallback and then reassigning in {#each} is broken #13822

wackbyte opened this issue Oct 23, 2024 · 5 comments
Labels
awaiting submitter needs a reproduction, or clarification

Comments

@wackbyte
Copy link
Contributor

wackbyte commented Oct 23, 2024

Describe the bug

In non-runes mode, destructuring an object with a fallback and then assigning to that variable in a callback does not seem to mutate it.

When the button is clicked in the REPL, this is the output:

1 false
2 false

It should be:

1 false
2 true

Reproduction

REPL

Logs

No response

System Info

REPL, Svelte 5.0.5, Firefox iOS

Severity

annoyance

@7nik
Copy link

7nik commented Oct 23, 2024

In Svelte 4 it doesn't work either.
In the runes mode, you get the each_item_invalid_assignment error on x = true.

@brunnerh
Copy link
Member

This seems like a bit of an edge case.
At least the state updates if actually stored somewhere.

@wackbyte
Copy link
Contributor Author

wackbyte commented Oct 23, 2024

Note that it works as expected if you don't have a fallback: REPL

@7nik
Copy link

7nik commented Oct 23, 2024

Destructuring with fallback internally is done as derived and I assume it doesn't see changes because the array isn't stateful. Defining it with a variable will make it coarsely reactive - the change will be propagated only in the next tick.
If you make the array deeply reactive, it will work.

@dummdidumm
Copy link
Member

Could you provide a more complete code example that better resembles your use case? As others pointed out, this doesn't work in Svelte 4 either, so I'm having a hard time to understand what is actually broken between 4 and 5 - if this is related to a 4->5 discrepancy at all.

@dummdidumm dummdidumm added the awaiting submitter needs a reproduction, or clarification label Oct 24, 2024
@wackbyte wackbyte closed this as completed Nov 4, 2024
@wackbyte wackbyte closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter needs a reproduction, or clarification
Projects
None yet
Development

No branches or pull requests

4 participants