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 update code being generated for module variable dependencies #5943

Closed
j-delaney opened this issue Jan 29, 2021 · 2 comments · Fixed by #9122
Closed

Fix update code being generated for module variable dependencies #5943

j-delaney opened this issue Jan 29, 2021 · 2 comments · Fixed by #9122

Comments

@j-delaney
Copy link
Contributor

As discussed in #5926 (comment), I'm already working on this and should hopefully have a PR up soon.

Svelte generates update code when a class: expression is dependent on a module variable but this shouldn't happen. The docs say:

Variables defined in module scripts are not reactive — reassigning them will not trigger a rerender even though the variable itself will update.

Test Case

https://svelte.dev/repl/ca93007e0e03454fbeda66bd6e2a6b9b?version=3.32.1
If you click the button, you'll see that o is not reactive (because it's a module var). But if you look at the JS output you'll see the component's update code isn't a noop like it should be, instead it's:

p(ctx, [dirty]) {
  if (dirty & /*o*/ 0) set_data(t0, o);
  
  if (dirty & /*o*/ 0) {
    toggle_class(div, "test", o);
  }
},

Cause

I'm pretty sure that this is because is_dynamic returns true for the module var. I'm looking into whether changing that behavior will break anything though.

@stale
Copy link

stale bot commented Jun 26, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 27, 2021
@stale
Copy link

stale bot commented Dec 24, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants