Skip to content

fix: resolve legacy component props equality for mutations #12348

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

Merged
merged 8 commits into from
Jul 8, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Jul 8, 2024

Fixes #12235

Copy link

changeset-bot bot commented Jul 8, 2024

🦋 Changeset detected

Latest commit: 82983fd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hold up, i don't think this is right

@Rich-Harris
Copy link
Member

Added the 'request changes' because I was still investigating and wanted to make sure we didn't merge hastily.

My concern was that this might be addressing the symptom rather than the cause, which is that sources inside a mutable proxy can diverge from their ground truth — in fact it's fixable with a much smaller diff:

get(target, prop, receiver) {
  // ...

  if (s !== undefined) {
+   if (!metadata.i && metadata.p !== s.v) {
+     // in mutable mode, it's possible for the source to diverge from the ground truth
+     s.v = proxy(metadata.t[prop]);
    }

    const value = get(s);
    return value === UNINITIALIZED ? undefined : value;
  }

  return Reflect.get(target, prop, receiver);
}

But I was wrong, because this is the only place where proxies can be mutable. I'm still going to make a couple of tweaks though:

  • we can make the test slightly simpler (one of the problems with our test suite is that tests often involve lots of moving parts, making it trickier to pinpoint the thing they're actually testing. In this case, we don't need to use an each block. This is top of mind for me at the moment because of feat: single-pass hydration #12335, which featured a lot of red herring test failures until everything worked perfectly)
  • we can now get rid of mutable proxies!

@trueadm trueadm merged commit ee47696 into main Jul 8, 2024
9 checks passed
@trueadm trueadm deleted the legacy-component-props-each branch July 8, 2024 19:29
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.

Svelte 5: Mutating data in load fn stops page reactivity
3 participants