Skip to content

chore: remove exposable #9783

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

Merged
merged 2 commits into from
Dec 5, 2023
Merged

chore: remove exposable #9783

merged 2 commits into from
Dec 5, 2023

Conversation

Rich-Harris
Copy link
Member

This is a more conservative approach to simplifying props than #9767 — I'm going to work in multiple manageable (and hopefully uncontroversial) stages rather than a few chonky PRs.

Right now, we have some clever-but-complicated machinery around bindings: instead of having a setter on the props object, in some cases we 'expose' the signal via the getter so that it can be set directly by the child.

This might have made sense in a world where we would set the prop on every mutation and didn't want to have chains of binding setters between the mutation and the ultimate signal update, but in a #9739 world it's just wantonly confusing (to this grug-brained developer, at least). It's much simpler to just always provide a setter. Doing so allows us to delete a bunch of internal library code and get rid of some global state that we need to check on every single get.

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
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

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

Copy link

changeset-bot bot commented Dec 5, 2023

⚠️ No Changeset found

Latest commit: bc10aba

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Rich-Harris
Copy link
Member Author

Oh, and I tweaked stuff around prop_source so that it takes a flag of options rather than taking immutable and call_default_value as separate args. This will pay dividends when we add a runes flag for disallowing fallbacks on bound props

@Rich-Harris Rich-Harris merged commit 10aacfa into main Dec 5, 2023
@Rich-Harris Rich-Harris deleted the simplify-props-2 branch December 5, 2023 18:56
Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

This change makes sense to me - it may have tiny performance implications but these are so rare that it doesn't warrant the additional logic, and this gets code size down a bit, removes some global flags (always good), and in the long run we don't need it anyway - win.

@@ -1548,11 +1484,9 @@ export function prop_source(props_obj, key, immutable, default_value, call_defau
return;
}

if (not_equal(immutable, propagating_value, possible_signal.v)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why can we remove this? I'm a bit surprised that no tests fail because removing this seems unrelated. Is it because the parent now always decides what to do with the update?

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.

3 participants