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(hydration): ignore host scope token in class validation #4865

Merged
merged 14 commits into from
Nov 15, 2024

Conversation

nolanlawson
Copy link
Collaborator

@nolanlawson nolanlawson commented Nov 14, 2024

Details

Fixes #4853

This is only a partial solution to the problem – I have a follow-up for further edge cases: #4866

With this PR, when we render the host scope token (e.g. class="lwc-abc123-host"), we also encode it as a data-lwc-host-scope-token attribute. This tells hydration to ignore certain classes during class validation, which avoids timing issues when using scoped styles and render().

To solve this, I'm also simplifying our class validation logic to only look at the differences between two Set<string>s. I just don't think it's worth it to care about classes in different orders, or duplicate classes – this doesn't affect CSS styling, and it makes the logic much simpler.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.

@nolanlawson nolanlawson merged commit d2be62a into master Nov 15, 2024
11 checks passed
@nolanlawson nolanlawson deleted the nolan/fix-hydration-bug branch November 15, 2024 20:40
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.

Hydration mismatch when using dynamic render() and scoped styles
3 participants