Describe the bug
In JS this:
const user = {name: "test"};
let {name, lastname} = user;
lastname = "test2";
console.log(user);
will result in:
It will not create the lastname property on the user.
In svelte doing something similar:
<script>
let users = $state([{name: "a"}]);
</script>
<!-- this creates the lastname on users[0] then assigns the value to it -->
<!-- which is not how js works -->
{#each users as {name, lastname}}
<div bind:this={lastname}></div>
{/each}
<br>
{JSON.stringify(users)}
will create:
[{"name":"a","lastname":{"__svelte_meta":{"loc":{"file":"App.svelte","line":9,"column":1}}}}]
It seems that it doesn't work for other binds tho, just for bind:this. This is a breaking change (bind:value={lastname} works in svelte4 using the each block arguments to bind to), which I didn't find documented, maybe I'm blind, just pointing this out as well.
Reproduction
- openup this REPL
- see the output :D
Logs
No response
System Info
Severity
annoyance