-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
chore: form state rework #14771
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
chore: form state rework #14771
Conversation
….create(null) because that isn't proxified by $state)
🦋 Changeset detectedLatest commit: 41cd636 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 |
| if (issues.$) { | ||
| release_overrides(updates); | ||
| } else { | ||
| update_all_versions(); |
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.
Didn't quite understand why that was necessary here; no test fails without it
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.
woah!
We now use
$stateinstead of$state.rawfor the internal representation ofvalue()/set(...). This has several advantages:$stateobject yourself intoset(...)and then just push to it, making array operations very easy (closes Request: Add field array helpers (push, pop, splice, etc) #14662)The reason I made this
$state.raworiginally is so thatfields.x.value()would fire even if something withinxwould update, but honestly that's a bad reason looking back. You can get that behavior by running JSON.stringify on the result, or you just access the properties you care about and it will all take care of it automatically.The one drawback is that prototype pollution prevention became a tiny but trickier, we now have to check for a set of keys. We should consider changing
$statein Svelte itself to also proxifyObject.create(null); maybe we can make that change when the experimental async flag is on?Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.