wip: skip hydration for empty forwarded slots
ci / test (push) Waiting to run Details
ci / continuous-release (push) Waiting to run Details

This commit is contained in:
daiwei 2025-07-31 21:13:01 +08:00
parent 1b0818bcde
commit 8d4f178dcc
2 changed files with 11 additions and 1 deletions

View File

@ -136,7 +136,7 @@ export function createSlot(
) )
} else { } else {
fragment = fragment =
(isHydrating || __DEV__) && !i isHydrating || __DEV__
? new DynamicFragment(SLOT_ANCHOR_LABEL) ? new DynamicFragment(SLOT_ANCHOR_LABEL)
: new DynamicFragment() : new DynamicFragment()
const isDynamicName = isFunction(name) const isDynamicName = isFunction(name)

View File

@ -139,7 +139,17 @@ export class DynamicFragment extends VaporFragment {
} }
setActiveSub(prevSub) setActiveSub(prevSub)
if (isHydrating && this.anchorLabel) { if (isHydrating && this.anchorLabel) {
// skip hydration for empty forwarded slots because
// the server output does not include their anchors
if (
this.nodes instanceof DynamicFragment &&
this.nodes.forwarded &&
!isValidBlock(this.nodes)
) {
return
}
this.hydrate(this.anchorLabel) this.hydrate(this.anchorLabel)
} }
} }