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

reactive dependency not referenced can't set to undefined initially #5600

Conversation

tanhauhau
Copy link
Member

Fixes #5538

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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

@tanhauhau tanhauhau force-pushed the tanhauhau/gh-5538-reactive-dependency-not-dirty branch from b5c9ef0 to 2109ee3 Compare October 28, 2020 00:27
@Conduitry
Copy link
Member

The failures here look to be all js sample tests. I haven't looked into whether they seem to be expected changes.

@tanhauhau tanhauhau force-pushed the tanhauhau/gh-5538-reactive-dependency-not-dirty branch from 71119a9 to 84c9145 Compare October 30, 2020 05:45
@tanhauhau
Copy link
Member Author

let me update the js sample tests.

let me explained a bit on what's changed.

<script>
   let a = 1;
   $: b = a;
   function update() {
       a = undefined;
   }
</script>
{ b }

because a is not referenced in the template, it wasn't included in the initial list of variables returned from instance. which means ctx[a_index] is undefined, even though value of a is not.

so when we call update, which $$invalidate(a_index, a = undefined), it didn't registered it as changed, since ctx[a_index] === undefined.

so, the changes is to include a into the initial list of variables. therefore there's some changes in the js samples.

@tanhauhau tanhauhau force-pushed the tanhauhau/gh-5538-reactive-dependency-not-dirty branch from 84c9145 to b5dc25f Compare October 30, 2020 05:53
@tanhauhau tanhauhau force-pushed the tanhauhau/gh-5538-reactive-dependency-not-dirty branch from b5dc25f to a6c5ee3 Compare October 30, 2020 06:40
@Conduitry Conduitry merged commit 1cc5bdb into sveltejs:master Nov 23, 2020
@tanhauhau tanhauhau deleted the tanhauhau/gh-5538-reactive-dependency-not-dirty branch November 25, 2020 06:42
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.

Store does not update component in certain combination with bind + #if + store
2 participants