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(SSR): patch scoped: true SSR-ed, slotted nodes next/prev sibling accessors #6057

Merged
merged 8 commits into from
Dec 18, 2024

Conversation

johnjenkins
Copy link
Contributor

@johnjenkins johnjenkins commented Nov 25, 2024

What is the current behavior?

Stencil scoped: true components don't do enough work to hide their internals from the browser. This can cause hydration errors when using SSR via meta-frameworks (nuxt, next etc).

GitHub Issue Number:
Fixes #6056

What is the new behavior?

As well as childNodes, children & childElementCount being patched via experimentalSlotFixes (or slotChildNodesFix), firstChild and lastChild accessors are now patched too; only returning slotted nodes.

Additionally, SSR slotted node accessors nextSibling, nextSiblingElement, previousSibling. previousSiblingElement are also patched, only returning 'lightDOM' nodes.

Documentation

Does this introduce a breaking change?

  • Yes
  • No

Testing

  • New unit tests
  • New wdio tests

Other information

Meta-frameworks (during SSR hydration) reconcile their DOM to check for rendering errors.

Typically this involves stepping over each node in the real DOM and comparing it with the expected output from the framework's VDOM.

When mis-matches are found, the existing SSR rendered nodes are removed and the client-side rendered nodes inserted instead, causing more work for the client runtime, a longer TTI and in Stencil's case, components that are broken.

This is an excerpt from Vue's hydration script:

image

@johnjenkins johnjenkins requested a review from a team as a code owner November 25, 2024 15:26
@johnjenkins johnjenkins changed the title chore: tidy feat(SSR): patch SSR, slotted nodes next/prev sibling accessors Nov 25, 2024
@johnjenkins johnjenkins marked this pull request as draft November 25, 2024 15:28
@johnjenkins johnjenkins changed the title feat(SSR): patch SSR, slotted nodes next/prev sibling accessors fix(SSR): patch SSR, slotted nodes next/prev sibling accessors Nov 25, 2024
@johnjenkins johnjenkins changed the title fix(SSR): patch SSR, slotted nodes next/prev sibling accessors fix(SSR): patch scoped: true SSR-ed, slotted nodes next/prev sibling accessors Nov 29, 2024
@johnjenkins johnjenkins marked this pull request as ready for review December 16, 2024 22:58
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Changes LGTM 👍

Once all checks are ✅ I can go ahead and merge

@christian-bromann christian-bromann added this pull request to the merge queue Dec 18, 2024
Merged via the queue into ionic-team:main with commit af102ce Dec 18, 2024
88 checks passed
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.

bug: Nuxt 3 hydration errors for scoped: true components
2 participants