]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: tweaks
authordaiwei <daiwei521@126.com>
Thu, 14 Aug 2025 13:31:46 +0000 (21:31 +0800)
committerdaiwei <daiwei521@126.com>
Thu, 14 Aug 2025 13:31:46 +0000 (21:31 +0800)
packages/runtime-vapor/src/dom/hydration.ts
packages/runtime-vapor/src/dom/node.ts

index 47b6a698667462cff2742ab9f527d6783f078bcb..09730e3292e071f2023f7e53d8affa03c6c9c55d 100644 (file)
@@ -223,3 +223,26 @@ function locateHydrationNodeByAnchor(
   }
   return null
 }
+
+export function skipBlockNodes(node: Node): Node {
+  while (node) {
+    if (isComment(node, `[${BLOCK_PREPEND_ANCHOR_LABEL}`)) {
+      node = locateEndAnchor(
+        node,
+        `[${BLOCK_PREPEND_ANCHOR_LABEL}`,
+        `${BLOCK_PREPEND_ANCHOR_LABEL}]`,
+      )!
+      continue
+    } else if (isComment(node, `[${BLOCK_INSERTION_ANCHOR_LABEL}`)) {
+      node = locateEndAnchor(
+        node,
+        `[${BLOCK_INSERTION_ANCHOR_LABEL}`,
+        `${BLOCK_INSERTION_ANCHOR_LABEL}]`,
+      )!
+      continue
+    }
+
+    break
+  }
+  return node
+}
index 6975f17d87d73865389da98dc39a0217a4302c22..19d906e27f91d169f80de7d4f68fd0b07564a53c 100644 (file)
@@ -1,9 +1,5 @@
-import { isComment, locateEndAnchor } from './hydration'
-import {
-  BLOCK_INSERTION_ANCHOR_LABEL,
-  BLOCK_PREPEND_ANCHOR_LABEL,
-  isInsertionAnchor,
-} from '@vue/shared'
+import { skipBlockNodes } from './hydration'
+import { isInsertionAnchor } from '@vue/shared'
 
 /*! #__NO_SIDE_EFFECTS__ */
 export function createElement(tagName: string): HTMLElement {
@@ -25,29 +21,6 @@ export function querySelector(selectors: string): Element | null {
   return document.querySelector(selectors)
 }
 
-function skipBlockNodes(node: Node): Node {
-  while (node) {
-    if (isComment(node, `[${BLOCK_PREPEND_ANCHOR_LABEL}`)) {
-      node = locateEndAnchor(
-        node,
-        `[${BLOCK_PREPEND_ANCHOR_LABEL}`,
-        `${BLOCK_PREPEND_ANCHOR_LABEL}]`,
-      )!
-      continue
-    } else if (isComment(node, `[${BLOCK_INSERTION_ANCHOR_LABEL}`)) {
-      node = locateEndAnchor(
-        node,
-        `[${BLOCK_INSERTION_ANCHOR_LABEL}`,
-        `${BLOCK_INSERTION_ANCHOR_LABEL}]`,
-      )!
-      continue
-    }
-
-    break
-  }
-  return node
-}
-
 /*! #__NO_SIDE_EFFECTS__ */
 const _txt: typeof _child = _child
 
@@ -78,15 +51,11 @@ export function _child(node: ParentNode): Node {
  */
 /*! #__NO_SIDE_EFFECTS__ */
 export function __child(node: ParentNode): Node {
-  let n = node.firstChild!
-  while (n && (isComment(n, '[') || isInsertionAnchor(n))) {
+  let n: Node = node.firstChild!
+  while (n && isInsertionAnchor(n)) {
     // skip block node
-    n = skipBlockNodes(n) as ChildNode
-    if (isComment(n, '[')) {
-      n = locateEndAnchor(n)!.nextSibling!
-    } else {
-      n = n.nextSibling!
-    }
+    n = skipBlockNodes(n)
+    n = n.nextSibling!
   }
 
   return n
@@ -119,11 +88,9 @@ export function _next(node: Node): Node {
  */
 /*! #__NO_SIDE_EFFECTS__ */
 export function __next(node: Node): Node {
-  // process fragment (<!--[-->...<!--]-->) as a single node
-  if (isComment(node, '[')) {
-    node = locateEndAnchor(node)!
+  if (isInsertionAnchor(node)) {
+    node = skipBlockNodes(node)
   }
-  node = skipBlockNodes(node)
   return node.nextSibling!
 }