]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: improve vdom slot hydration handling
authordaiwei <daiwei521@126.com>
Thu, 14 Aug 2025 06:24:43 +0000 (14:24 +0800)
committerdaiwei <daiwei521@126.com>
Thu, 14 Aug 2025 06:24:43 +0000 (14:24 +0800)
packages/runtime-vapor/src/vdomInterop.ts

index 74982b4d574c1bc764d1cb4c9641d7c064fa0f60..fe12fddbfd767998906cfb39b9dfbdd4b63fa154 100644 (file)
@@ -388,7 +388,12 @@ function renderVDOMSlot(
       }
       if (isValidSlot) {
         if (isHydrating) {
-          hydrateVNode(vnode!, parentComponent as any)
+          // if slot content is a vnode, hydrate it
+          // otherwise, it is a vapor Block that is already hydrated during
+          // renderSlot
+          if (isVNode(vnode)) {
+            hydrateVNode(vnode!, parentComponent as any)
+          }
         } else {
           if (fallbackNodes) {
             remove(fallbackNodes, parentNode)
@@ -416,7 +421,9 @@ function renderVDOMSlot(
           fallbackNodes = fallback(internals, parentComponent)
           if (isHydrating) {
             // hydrate fallback
-            hydrateVNode(fallbackNodes as any, parentComponent as any)
+            if (isVNode(vnode)) {
+              hydrateVNode(fallbackNodes as any, parentComponent as any)
+            }
           } else {
             // mount fallback
             if (oldVNode) {
@@ -516,5 +523,6 @@ function hydrateVNode(
     null,
     false,
   )
-  if (nextNode) advanceHydrationNode(nextNode)
+  if (nextNode) setCurrentHydrationNode(nextNode)
+  else advanceHydrationNode(node)
 }