-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: allow mutation of data and form props in Svelte 5 #11809
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
base: main
Are you sure you want to change the base?
Conversation
By doing `bind:data/form`, the layout/child components are allowed to mutate those properties Related sveltejs/svelte#9905
🦋 Changeset detectedLatest commit: c7692a3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I guess it makes sense for backwards compatibility. Is it what we want long-term? I'm not sure if we should remove the |
We've officially encouraged this pattern in the past in order to do optimistic updates, so I don't think we can remove it in the future because that would mean you can't do that pattern anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but probably wouldn't hurt to have rich take a look since I haven't kept up with svelte 5 as well
I'm torn on this. We definitely need some version of this, but in a world of proxied state it kinda feels like mutating I think this pattern might be better: -data.stuff = new_stuff;
+data = { ...data, stuff: new_stuff }; Slightly more verbose, but cleaner in my view. Is there any reason this wouldn't work? |
No reason this wouldn't work, just that we ourselves did |
By doing
bind:data/form
, the layout/child components are allowed to mutate those propertiesRelated sveltejs/svelte#9905 / sveltejs/svelte#10084
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits