Repository navigation
fix(runtime): keep SSR slot content visible across hydration order - #7013
Merged
johnjenkins merged 4 commits intoNov 24, 2026
Merged
johnjenkins merged 4 commits into
johnjenkins merged 4 commits into
Conversation
Content a light-DOM component renders into another light-DOM component's default slot disappeared after client hydration since 4.41.0 (see stenciljs#6934): the runtime set `hidden` on it once the client took over. SSR serializes a node's slot assignment as an `s-sn` attribute on the element. The owning host converts it into the `s-sn` property only when it hydrates itself. When the wrapper component hydrates first, `addSlottedNodes` ran before that conversion happened, skipped the node (it matched neither `slot` attribute nor `s-sn` property), so the node never got `s-sh` - and the post-render hiding pass from stenciljs#6514 then hid it, since it looks exactly like content without a slot to go to. Nothing relocated it afterwards, because SSR had already placed it. `addSlottedNodes` now also honors the `s-sn` attribute, so nodes SSR already assigned to the slot are collected regardless of which host hydrates first. Verified against the reproduction from stenciljs#6934: SSR markup hydrates with the content visible, as in 4.40.1.
johnjenkins
approved these changes
Nov 24, 2026
johnjenkins
enabled auto-merge (squash)
November 24, 2026 15:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
Content that a light-DOM component renders into another light-DOM component's default slot disappears after client hydration: since 4.41.0 the runtime sets
hidden=""on it. In a real app every layout section that renders into a wrapper's slot goes blank once the client hydrates, which takes the LCP element with it. 4.40.1 was fine, and client-only rendering never hits this.The reporter's analysis in #6934 traced the whole chain, and I could reproduce every step with their inline repro:
SSR serializes a node's slot assignment as an
s-snattribute on the element. The owning host only converts it into thes-snproperty while it hydrates itself. When the wrapper hydrates first,addSlottedNodesruns before that conversion happened: the projected node matches neither theslotattribute nor thes-snproperty, so it is not collected and never getss-sh. The post-render hiding pass from #6514 then hides it, because at that point it looks exactly like content without a slot to go to. Nothing relocates it later, since SSR had already placed it. Hydration order decides whether you see the bug - which is why it is easy to miss.GitHub Issue Number: #6934
What is the new behavior?
addSlottedNodesalso honors thes-snattribute, so nodes SSR already assigned to a slot are collected no matter which host hydrates first. That is the fix direction the reporter suggested and verified, and I implemented it in the same shape.My first instinct was the smaller-looking one: gate the hiding pass back to what it was before #6514. The reporter explicitly ruled that out, and rightly so - the pass correctly hides stale server markup in nodes cloned on the client, and restoring the old flag-gated behavior would bring that problem back. Collecting the node at the source is the fix that keeps #6514 working.
I verified the whole thing against the reporter's inline reproduction (two light-DOM components,
renderToString, headless Chrome): without the change,.innercomes backhiddenwith exit code 1; with it,.innerstays visible, matching 4.40.1. I ran that both ways myself - stash the fix, rebuild, watch it fail, restore it, watch it pass.Documentation
No docs change needed; this restores behavior the SSR docs already describe.
Does this introduce a breaking change?
Testing
test/wdio/ssr-hydration/that reproduces the hydration order from the issue (wrapper hydrates before the owning host, set up via the existingdefineCustomElementpattern) and asserts the projected content stays visible. Without the fix this test fails; I ran it both ways.<slot>#6514 behavior this fix must not touch (scoped component, dynamic slot toggle: hidden without slot, visible with slot, hidden again) - theaddSlottedNodeschange only affects the SSR-attribute path, which does not exist in client-only rendering, but I wanted that pinned rather than assumed.ssr-hydrationwdio specs green (25 tests). The broader e2e/wdio suites beyondssr-hydrationI did not run locally.Thank you to the reporter of #6934 - the bisect, the traced hydration order and the verified fix direction in the issue made this a small change instead of a long hunt.