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

$$restProps is updated even when normal prop values are changed #7004

Closed
aradalvand opened this issue Dec 9, 2021 · 4 comments
Closed

$$restProps is updated even when normal prop values are changed #7004

aradalvand opened this issue Dec 9, 2021 · 4 comments

Comments

@aradalvand
Copy link

aradalvand commented Dec 9, 2021

Describe the bug

This is a small thing but I wanted to know whether it could be fixed or it was done intentionally. Here's the REPL.

What's happening here in this example is that whenever the value of the prop rating changes, it's as if $$restProps is also updated, and as a result, every part of the component that's referencing $$restProps would be notified and re-rendered, even though the contents of $$restProps haven't changed at all.

For $$props this would of course make sense, but not for $$restProps since the rating prop is a normal component prop and would never be included in $$restProps. So, any changes to it shouldn't really concern $$restProps at all.

This is a small inefficiency and I was curious as to why it happens.
Thanks.

Severity

annoyance

@baseballyama
Copy link
Member

I think the root cause is the same as #6921

In order to decide whether to recalculate a $ part, the runtime determines if a dependent variable(s) has changed.
However, as shown in the following runtime code, object is always considered to have changed.
Therefore a $ part is to be recalculated more than necessary.

export function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}

This seems to be the intended behavior, at least from the code.

@aradalvand
Copy link
Author

aradalvand commented Dec 24, 2021

Okay but still nothing in the $$restProps has actually changed, I think Svelte should take a smarter approach in this regard. Don't you agree?

@baseballyama
Copy link
Member

Can you explain the benefit of eliminating this small inefficiency?
I think it's possible to eliminate this inefficiency, but there is a trade-off with performance.
So I think there needs to be a clear reason to implement it.

@baseballyama
Copy link
Member

baseballyama commented Aug 6, 2022

Close this because there was no clear explanation here.
Nevertheless, the conservative reactivity could be improved in Svelte4.

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

No branches or pull requests

2 participants