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

breaking: apply fallback value every time in runes mode #10797

Merged
merged 5 commits into from
Mar 22, 2024

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Mar 13, 2024

closes #9948

Draft mode because I came across an interesting question with regards to accessors and default values. Right now, setting a component property to undefined through its accessor (component.property = undefined) will set it to actually undefined instead of the default value. One could argue this is correct since implementation-wise this isn't looking for what's coming in from the property, instead it's updating the internal state with a new value. Semantically one could argue it should apply the fallback value (change should be straightforward, change the setter from set x($$value) {..} to set x($$value = fallback) {..}) since it's setting the property, just through another path. Semantically one could also argue that setting it through the accessor is more direct than through a property, and so it shouldn't apply.
We need to make a decision here. I slightly lean towards "applies default value".
Update: decided

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 Mar 13, 2024

🦋 Changeset detected

Latest commit: 6973746

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

I slightly lean towards "applies default value"

same. I also lean strongly towards 'nuke accessors from orbit as soon as we can'

@Conduitry
Copy link
Member

Yup, I agree with all of the above - apply the default value, and nuke accessors ASAP. I think it's acceptable to have a getter return a different value from the one you just called the setter with.

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: default property value should be real and not initial|undefined
3 participants