Skip to content

Commit 98d6f7b

Browse files
authored
refactor(runtime-vapor): replace findBlockNode with locateNextNode in v-for hydration (#14585)
1 parent 419b6cb commit 98d6f7b

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

packages/runtime-vapor/src/apiCreateFor.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ import {
1313
} from '@vue/reactivity'
1414
import { isArray, isObject, isString } from '@vue/shared'
1515
import { createComment, createTextNode } from './dom/node'
16-
import {
17-
type Block,
18-
applyTransitionHooks,
19-
findBlockNode,
20-
insert,
21-
remove,
22-
} from './block'
16+
import { type Block, applyTransitionHooks, insert, remove } from './block'
2317
import { queuePostFlushCb, warn } from '@vue/runtime-dom'
2418
import { currentInstance, isVaporComponent } from './component'
2519
import {
@@ -35,6 +29,7 @@ import {
3529
isComment,
3630
isHydrating,
3731
locateHydrationNode,
32+
locateNextNode,
3833
setCurrentHydrationNode,
3934
} from './dom/hydration'
4035
import { ForFragment, VaporFragment } from './fragment'
@@ -144,11 +139,11 @@ export const createFor = (
144139

145140
if (!isMounted) {
146141
isMounted = true
142+
let nextNode
147143
for (let i = 0; i < newLength; i++) {
148-
const nodes = mount(source, i).nodes
149-
if (isHydrating) {
150-
setCurrentHydrationNode(findBlockNode(nodes!).nextNode)
151-
}
144+
if (isHydrating) nextNode = locateNextNode(currentHydrationNode!)
145+
mount(source, i)
146+
if (isHydrating && nextNode) setCurrentHydrationNode(nextNode)
152147
}
153148

154149
if (isHydrating) {

0 commit comments

Comments
 (0)