-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Adding a comment changes the semantics of the code significantly, as well a related potential reactivity bug #9088
Comments
Seems related to #4265 |
The |
@dummdidumm, Not opposed either way if it's still decided the reactivity part of this bug is a duplicate, just voicing my additional thoughts. Thanks for the help! edit: I found #7749 which does seem to be a duplicate of my reactivity issue, minus the comment weirdness. However, it has remained unresolved/unassigned since August, 2022. After seeing the long history of #4265 without any confirmation of a fix, is there any way to get this issue recognized by someone on the team? This bug has lead to many lost hours by 10's of developers by the looks of it. |
Hello, First, it seem that invalidate a reactive declaration will invalidate all his dependencies. Exemple : // This line
namesCopy = namesCopy;
// is converted to
($$invalidate(0, namesCopy), $$invalidate(2, names));
// but IMHO, it should be :
$$invalidate(0, namesCopy); I don't understand why, but it seems to be intentional, based on this code : svelte/packages/svelte/src/compiler/compile/render_dom/invalidate.js Lines 129 to 140 in f4c4d99
And the different behavior with the comment seems to come from there : svelte/packages/svelte/src/compiler/compile/render_dom/invalidate.js Lines 50 to 57 in f4c4d99
=> The nodes_match() will be falsy with a comment, since it is only present on one of the nodes. |
Hello @Kcwidman
|
apart from the comment problem, you can prevent the |
related to issue #9088 it doesn't solve the main problem of dependencies getting invalidated whenever value of a variable gets changed. but it fixes the behavior difference between the code with and without comments
related to issue sveltejs#9088 it doesn't solve the main problem of dependencies getting invalidated whenever value of a variable gets changed. but it fixes the behavior difference between the code with and without comments
Describe the bug
Adding a comment changes the semantics of the code. In fact, adding a comment fixes another presumed reactivity bug.
Let's walk through the original presumed bug first, then I'll explain the bizarre comment behavior.
For the rest of this report, I'll be referring to this REPL which replicates the issue.
Note: I have also replicated this with a running svelte-kit application as well.
Replication:
Bug:
The original list will have reactivity triggered on it even though it's been copied by value. The expected behavior is that the original list should not have reactivity triggered on it all. This is validated in the JS output, showing that the clickAction handler invalidates both names and namesCopy.
Findings:
the behavior works as expected
code (this is also reflected in the JS output)
Reproduction
Replication is mentioned in tandem with bug description.
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: