Skip to content

Conversation

@dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Oct 20, 2025

We now use $state instead of $state.raw for the internal representation of value()/set(...). This has several advantages:

The reason I made this $state.raw originally is so that fields.x.value() would fire even if something within x would 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 $state in Svelte itself to also proxify Object.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:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: 41cd636

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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();
Copy link
Member Author

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

Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah!

@dummdidumm dummdidumm merged commit a78d8b1 into main Oct 20, 2025
38 of 39 checks passed
@dummdidumm dummdidumm deleted the form-state-rework branch October 20, 2025 21:00
@github-actions github-actions bot mentioned this pull request Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request: Add field array helpers (push, pop, splice, etc)

3 participants