Skip to content
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

fix: keep default values of props a proxy after reassignment #11860

Merged

Conversation

paoloricciuti
Copy link
Member

Svelte 5 rewrite

Closes #11859

Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (main).

If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is svelte-4 and not main.

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 May 31, 2024

🦋 Changeset detected

Latest commit: 696a51b

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

This PR includes changesets to release 1 package
Name Type
svelte 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

@Rich-Harris
Copy link
Member

This might seem like a side-issue but for me this is the straw that broke the camel's back: serialize_set_binding is completely out of control and I think we need to totally refactor it. I'm looking at the code and it's just so hard to follow — it's not the worst part of our codebase but it's up there. Does anyone else share this concern?

As a more immediate matter, initial_bindable_proxy doesn't really accurately tell me what kind of value this is and in what circumstances it would be true or false — it's unrelated to whether it's even a prop, let alone whether it's bindable. I think it should have a more descriptive name, and we should try to avoid things like binding.initial && (as opposed to binding.initial !== null &&)

@paoloricciuti
Copy link
Member Author

This might seem like a side-issue but for me this is the straw that broke the camel's back: serialize_set_binding is completely out of control and I think we need to totally refactor it. I'm looking at the code and it's just so hard to follow — it's not the worst part of our codebase but it's up there. Does anyone else share this concern?

Working on it for this PR didn't seem completely crazy but there's definitely a lot in there.

As a more immediate matter, initial_bindable_proxy doesn't really accurately tell me what kind of value this is and in what circumstances it would be true or false — it's unrelated to whether it's even a prop, let alone whether it's bindable. I think it should have a more descriptive name, and we should try to avoid things like binding.initial && (as opposed to binding.initial !== null &&)

You are right: I could think of a better name and initially I thought this was just for bindable properties. I think a better name could be is_initial_proxied maybe? And obviously I can refactor to the more precise bind.initial !==null and keep a not for future PRs.

However at this point what do we want to do with the method? Should I refactor the name and check and then we think how we want to handle the method either in this or another PR?

@Rich-Harris
Copy link
Member

I guess a more comprehensive refactor could take some time, and in the meantime there's a bug. So yeah, let's go ahead with those changes — thanks!

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.

Svelte 5: Properties on fallback prop value only initially reactive
3 participants