Skip to content

chore: tidy up hydration code #10891

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 16 commits into from
Mar 23, 2024
Merged

chore: tidy up hydration code #10891

merged 16 commits into from
Mar 23, 2024

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Mar 23, 2024

A few minor cosmetic changes:

  • current_hydration_fragment -> hydrate_nodes — three syllables instead of seven, and avoids a confusing use of the word 'fragment' (which implies a DocumentFragment). In some cases, this allows Prettier to put things on a single line where previously it would have taken more
  • instead of doing set_current_hydration_fragment(null) and set_current_hydration_fragment([]) as an indirect way of setting hydrating to false or true (it has no other effect), we just have a set_hydrating function. This is much easier to understand
  • outside hydration.js, get_hydration_fragment and set_current_hydration_fragment were always called together. The intent of this pair of functions is to update hydrate_nodes, and as such they have been replaced with a combined update_hydrate_nodes(...) function
  • moved capture_fragment_from_node into hydration.js
  • simplified a few functions a bit

I believe there are some further opportunities for simplification but wanted to land this first to keep PRs manageable. No behaviour changes so I'll self-merge once green

Copy link

changeset-bot bot commented Mar 23, 2024

⚠️ No Changeset found

Latest commit: d14efd8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@Rich-Harris Rich-Harris changed the title Hydration station chore: tidy up hydration code Mar 23, 2024
@Rich-Harris Rich-Harris merged commit dfd1819 into main Mar 23, 2024
@Rich-Harris Rich-Harris deleted the hydration-station branch March 23, 2024 17:21
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.

1 participant