From: daiwei Date: Thu, 31 Jul 2025 13:13:01 +0000 (+0800) Subject: wip: skip hydration for empty forwarded slots X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d4f178dcccf0ee6261692ab62dbbb69c9f9e65b;p=thirdparty%2Fvuejs%2Fcore.git wip: skip hydration for empty forwarded slots --- diff --git a/packages/runtime-vapor/src/componentSlots.ts b/packages/runtime-vapor/src/componentSlots.ts index 9ae3bd249..3b4adeed9 100644 --- a/packages/runtime-vapor/src/componentSlots.ts +++ b/packages/runtime-vapor/src/componentSlots.ts @@ -136,7 +136,7 @@ export function createSlot( ) } else { fragment = - (isHydrating || __DEV__) && !i + isHydrating || __DEV__ ? new DynamicFragment(SLOT_ANCHOR_LABEL) : new DynamicFragment() const isDynamicName = isFunction(name) diff --git a/packages/runtime-vapor/src/fragment.ts b/packages/runtime-vapor/src/fragment.ts index b978298a6..f21ac9b57 100644 --- a/packages/runtime-vapor/src/fragment.ts +++ b/packages/runtime-vapor/src/fragment.ts @@ -139,7 +139,17 @@ export class DynamicFragment extends VaporFragment { } setActiveSub(prevSub) + 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) } }