-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Default data not re-added when removing property value #1467
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
Comments
Ha my mistake, I thought that for a minute because I didn't realize svelte treats |
@jacobmischka I think the misunderstanding here is that the To get the behavior you want, a computed property is probably best. See this version, where |
That makes sense. I suppose this is more of a feature request than a bug report, because I think it would be nice if it behaved that way. Though you're right, computed properties could work just as well, thanks for the suggestion. |
Even if #1434 is implemented, I imagine it will be "don't touch the current values when |
Going to close this as the behaviour is expected. In v3 it's a good deal easier to patch objects as opposed to replacing them — instead of this.set({nestedData: { added: 'updated!' }}); it's possible to do nestedData.added = 'updated!'; thus leaving |
The current behavior makes sense, but it would be great if default data could somehow be reinjected if previously-provided data gets removed. It can particularly get in the way when using spread for props.
REPL: https://svelte.technology/repl?version=2.6.1&gist=b2cd6467f026d0b3a0857d248d44f830
It may be sort of related to #1434, but I actually want the falsey values passed down, I just want the default data ones to re-take effect.
I guess I basically am wanting an implicit something like this:
Edit: I guess using Object.assign for this doesn't work, becuase
undefined
is indeed a value which is overriding the defaults. I wonder if this is what's causing the issue in the first place.Thanks!
The text was updated successfully, but these errors were encountered: