فهرست منبع

fix: preserve current hydration node during slot insertion

daiwei 11 ماه پیش
والد
کامیت
a6e039865e
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      packages/runtime-vapor/src/component.ts

+ 8 - 1
packages/runtime-vapor/src/component.ts

@@ -568,12 +568,19 @@ export function createComponentWithFallback(
   }
 
   if (rawSlots) {
-    isHydrating && setCurrentHydrationNode(el.firstChild)
+    let prev: Node
+    if (isHydrating) {
+      prev = currentHydrationNode!
+      setCurrentHydrationNode(el.firstChild)
+    }
     if (rawSlots.$) {
       // TODO dynamic slot fragment
     } else {
       insert(getSlot(rawSlots as RawSlots, 'default')!(), el)
     }
+    if (isHydrating) {
+      setCurrentHydrationNode(prev!)
+    }
   }
 
   if (!isHydrating && _insertionParent) {