]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: skip hydration for empty forwarded slots
authordaiwei <daiwei521@126.com>
Thu, 31 Jul 2025 13:13:01 +0000 (21:13 +0800)
committerdaiwei <daiwei521@126.com>
Thu, 31 Jul 2025 13:13:01 +0000 (21:13 +0800)
packages/runtime-vapor/src/componentSlots.ts
packages/runtime-vapor/src/fragment.ts

index 9ae3bd2497f8a131faa2ef1ec828dc5b9be42179..3b4adeed9f1a9cfec9eecf05635f86abb5b831ea 100644 (file)
@@ -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)
index b978298a6d7a5484d1ce4ec60c43584eef0a270d..f21ac9b577d4b7339ac6a9aad4afa1592c61efb9 100644 (file)
@@ -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)
     }
   }