daiwei 2 недель назад
Родитель
Сommit
27aa61e290

+ 1 - 1
packages/runtime-vapor/src/block.ts

@@ -334,7 +334,7 @@ export function normalizeBlock(block: Block): Node[] {
   return nodes
 }
 
-export function findBlockNode(block: Block): {
+export function findBlockBoundary(block: Block): {
   parentNode: Node | null
   nextNode: Node | null
 } {

+ 3 - 2
packages/runtime-vapor/src/component.ts

@@ -41,7 +41,7 @@ import {
   warn,
   warnExtraneousAttributes,
 } from '@vue/runtime-dom'
-import { type Block, findBlockNode, insert, isBlock, remove } from './block'
+import { type Block, findBlockBoundary, insert, isBlock, remove } from './block'
 import {
   type ShallowRef,
   markRaw,
@@ -486,7 +486,8 @@ export function createComponent(
         if (
           instance.block &&
           hydrationClose &&
-          findBlockNode(instance.block).nextNode === hydrationClose.nextSibling
+          findBlockBoundary(instance.block).nextNode ===
+            hydrationClose.nextSibling
         ) {
           setCurrentHydrationNode(hydrationClose)
         }

+ 3 - 3
packages/runtime-vapor/src/components/KeepAlive.ts

@@ -20,7 +20,7 @@ import {
   warn,
   watch,
 } from '@vue/runtime-dom'
-import { type Block, findBlockNode, move, remove } from '../block'
+import { type Block, findBlockBoundary, move, remove } from '../block'
 import {
   type VaporComponent,
   type VaporComponentInstance,
@@ -136,7 +136,7 @@ const VaporKeepAliveImpl = defineVaporComponent({
           if (cached !== current) {
             // Cached blocks may contain interop children whose VDOM teardown
             // is owned by remove(), not scope.stop().
-            const parentNode = findBlockNode(cached).parentNode
+            const parentNode = findBlockBoundary(cached).parentNode
             if (parentNode) remove(cached, parentNode as ParentNode)
           }
         })
@@ -281,7 +281,7 @@ const VaporKeepAliveImpl = defineVaporComponent({
       if (cached && (!current || cached !== current)) {
         unsetShapeFlag(cached)
         // A pruned branch may still be leaving and not yet be in storageContainer.
-        const parentNode = findBlockNode(cached).parentNode
+        const parentNode = findBlockBoundary(cached).parentNode
         if (parentNode) remove(cached, parentNode as ParentNode)
       } else if (current) {
         unsetShapeFlag(current)

+ 2 - 2
packages/runtime-vapor/src/fragment.ts

@@ -9,7 +9,7 @@ import {
   type BlockFn,
   type TransitionOptions,
   type VaporTransitionHooks,
-  findBlockNode,
+  findBlockBoundary,
   insert,
   isValidBlock,
   remove,
@@ -729,7 +729,7 @@ export class DynamicFragment extends VaporFragment {
         parentNode = currentSlotEndAnchor.parentNode
         nextNode = currentSlotEndAnchor
       } else {
-        const node = findBlockNode(this.nodes)
+        const node = findBlockBoundary(this.nodes)
         parentNode = node.parentNode
         nextNode = node.nextNode
       }

+ 5 - 5
packages/runtime-vapor/src/hmr.ts

@@ -4,7 +4,7 @@ import {
   pushWarningContext,
   setCurrentInstance,
 } from '@vue/runtime-dom'
-import { type Block, findBlockNode, insert, remove } from './block'
+import { type Block, findBlockBoundary, insert, remove } from './block'
 import {
   type VaporComponent,
   type VaporComponentInstance,
@@ -19,7 +19,7 @@ import { isFragment } from './fragment'
 import { isKeepAliveEnabled } from './keepAlive'
 
 export function hmrRerender(instance: VaporComponentInstance): void {
-  const { parentNode, nextNode: anchor } = findBlockNode(instance.block)
+  const { parentNode, nextNode: anchor } = findBlockBoundary(instance.block)
   const parent = parentNode as ParentNode
   // reset scope to avoid stale effects
   instance.scope.reset()
@@ -45,7 +45,7 @@ export function hmrReload(
     instance.parent.hmrRerender!()
     return
   }
-  const { parentNode, nextNode: anchor } = findBlockNode(instance.block)
+  const { parentNode, nextNode: anchor } = findBlockBoundary(instance.block)
   const parent = parentNode as ParentNode
   unmountComponent(instance, parent)
   const parentInstance = instance.parent as VaporComponentInstance | null
@@ -73,7 +73,7 @@ export function hmrReload(
  * dev only
  * update parentInstance.block to ensure that the correct parent and
  * anchor are found during parentInstance HMR rerender/reload, as
- * `findBlockNode` relies on the current instance.block
+ * `findBlockBoundary` relies on the current instance.block
  */
 function updateParentBlockOnHmrReload(
   parentInstance: VaporComponentInstance | null,
@@ -94,7 +94,7 @@ function updateParentBlockOnHmrReload(
  * during root component HMR reload, since the old component will be unmounted
  * and a new one will be mounted, we need to update the teleport's nodes
  * to ensure that the correct parent and anchor are found during parentInstance
- * HMR rerender/reload, as `findBlockNode` relies on the current instance.block
+ * HMR rerender/reload, as `findBlockBoundary` relies on the current instance.block
  */
 export function updateParentTeleportOnHmrReload(
   instance: VaporComponentInstance,