Closed
Description
Describe the bug
It seems that $state()
s created by copying a $state.snapshot()
behave differently.
I have created a small example that does the following:
- Create a small
$state()
calleduser
- Pass the
user
to a component - The component creates a new
$state()
by cloning data in this way:$state($state.snapshot(_user))
- The new
user
object is passed to some<input>
types with thebind:value
directive - When the save button is pressed, the old values are returned to the
onsave
callback ... unless you spread the object.
So, in short:
onsave(user)
will return the OLD values, even if they are saved inside the newuser
objectonsave({...user})
will return the correct values
Tested against: svelte 5.0.0-next.243
Reproduction
I have created a small REPL Here
Logs
No response
System Info
System:
OS: Linux 6.8 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
CPU: (24) x64 AMD Ryzen 9 7900X 12-Core Processor
Memory: 53.73 GB / 62.01 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
pnpm: 9.9.0 - ~/.local/share/pnpm/pnpm
bun: 1.0.0 - ~/.bun/bin/bun
Browsers:
Brave Browser: 127.1.68.137
Chrome: 127.0.6533.88
### Severity
blocking all usage of svelte
Metadata
Metadata
Assignees
Labels
No labels