]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: update
authordaiwei <daiwei521@126.com>
Mon, 4 Aug 2025 05:44:57 +0000 (13:44 +0800)
committerdaiwei <daiwei521@126.com>
Mon, 4 Aug 2025 05:51:37 +0000 (13:51 +0800)
packages/runtime-vapor/src/apiCreateFor.ts
packages/runtime-vapor/src/dom/hydration.ts
packages/runtime-vapor/src/fragment.ts

index 3104f4b030aadba4024918f14f19c6f26f78d8c3..290136101c1e9435622d00e12c265e81502a0418 100644 (file)
@@ -25,7 +25,6 @@ import {
   isHydrating,
   locateHydrationNode,
   locateVaporFragmentAnchor,
-  updateNextChildToHydrate,
 } from './dom/hydration'
 import { ForFragment, VaporFragment } from './fragment'
 import {
@@ -97,16 +96,7 @@ export const createFor = (
   // useSelector only
   let currentKey: any
   let parentAnchor: Node
-  if (isHydrating) {
-    parentAnchor =
-      locateVaporFragmentAnchor(currentHydrationNode!, FOR_ANCHOR_LABEL) ||
-      // fallback to the fragment end anchor if in ssr slots vnode fallback
-      locateVaporFragmentAnchor(currentHydrationNode!, ']')!
-    if (__DEV__ && !parentAnchor) {
-      // this should not happen
-      throw new Error(`v-for fragment anchor node was not found.`)
-    }
-  } else {
+  if (!isHydrating) {
     parentAnchor = __DEV__ ? createComment('for') : createTextNode()
   }
 
@@ -135,12 +125,19 @@ export const createFor = (
     if (!isMounted) {
       isMounted = true
       for (let i = 0; i < newLength; i++) {
-        // TODO add tests
-        if (isHydrating && i > 0 && _insertionParent) {
-          updateNextChildToHydrate(_insertionParent)
-        }
         mount(source, i)
       }
+
+      if (isHydrating) {
+        parentAnchor =
+          locateVaporFragmentAnchor(currentHydrationNode!, FOR_ANCHOR_LABEL) ||
+          // fallback to the fragment end anchor if in ssr slots vnode fallback
+          locateVaporFragmentAnchor(currentHydrationNode!, ']')!
+        if (__DEV__ && !parentAnchor) {
+          // this should not happen
+          throw new Error(`v-for fragment anchor node was not found.`)
+        }
+      }
     } else {
       parent = parent || parentAnchor!.parentNode
       if (!oldLength) {
@@ -473,7 +470,7 @@ export const createFor = (
   }
   if (isHydrating) {
     advanceHydrationNode(
-      _insertionAnchor !== undefined ? _insertionParent! : parentAnchor,
+      _insertionAnchor !== undefined ? _insertionParent! : parentAnchor!,
     )
   }
 
index b070158d3cd708bfa63818747e3a2a6416ab025f..5edf0ec5f4d2acbdd4da438af67f40afeb087278 100644 (file)
@@ -73,7 +73,7 @@ export function hydrateNode(node: Node, fn: () => void): void {
 }
 
 export let adoptTemplate: (node: Node, template: string) => Node | null
-export let locateHydrationNode: (isFragment?: boolean) => void
+export let locateHydrationNode: () => void
 
 type Anchor = Comment & {
   // cached matching fragment end to avoid repeated traversal
@@ -114,19 +114,7 @@ function adoptTemplateImpl(node: Node, template: string): Node | null {
   return node
 }
 
-const childToHydrateMap = new WeakMap<ParentNode, Node>()
-
-export function updateNextChildToHydrate(parent: ParentNode): void {
-  let nextNode = childToHydrateMap.get(parent)
-  if (nextNode) {
-    nextNode = __next(nextNode)
-    if (nextNode) {
-      childToHydrateMap.set(parent, (currentHydrationNode = nextNode))
-    }
-  }
-}
-
-function locateHydrationNodeImpl(isFragment?: boolean): void {
+function locateHydrationNodeImpl(): void {
   let node: Node | null
   // prepend / firstChild
   if (insertionAnchor === 0) {
@@ -141,23 +129,7 @@ function locateHydrationNodeImpl(isFragment?: boolean): void {
   } else {
     node = currentHydrationNode
     if (insertionParent && (!node || node.parentNode !== insertionParent)) {
-      node =
-        childToHydrateMap.get(insertionParent) ||
-        __nthChild(insertionParent, insertionParent.$dp || 0)
-    }
-
-    // locate slot fragment start anchor
-    // if (isFragment && node && !isComment(node, '[')) {
-    //   node = locateVaporFragmentAnchor(node, '[')!
-    // } else {
-    //   while (node && isNonHydrationNode(node)) {
-    //     node = node.nextSibling!
-    //   }
-    // }
-
-    if (insertionParent && node) {
-      const nextNode = node.nextSibling
-      if (nextNode) childToHydrateMap.set(insertionParent, nextNode)
+      node = __nthChild(insertionParent, insertionParent.$dp || 0)
     }
   }
 
index 92b5a353c734d5e5eedd9cb8de481f36b07897a7..c4ddc92f9af2e4e28d116612cb5a4cbef2cdc963 100644 (file)
@@ -64,7 +64,7 @@ export class DynamicFragment extends VaporFragment {
   constructor(anchorLabel?: string) {
     super([])
     if (isHydrating) {
-      locateHydrationNode(anchorLabel === 'slot')
+      locateHydrationNode()
       this.anchorLabel = anchorLabel
     } else {
       this.anchor =