Skip to content

Commit 00266de

Browse files
committed
fix: ensure self anchor is inserted during hydration
1 parent c52f8d8 commit 00266de

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/runtime-vapor/src/vdomInterop.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ const vaporInteropImpl: Omit<
6161
'vdomMount' | 'vdomUnmount' | 'vdomSlot'
6262
> = {
6363
mount(vnode, container, anchor, parentComponent) {
64-
let selfAnchor: Node | null = null
64+
let selfAnchor = (vnode.el = vnode.anchor = createTextNode())
6565
if (!isHydrating) {
66-
selfAnchor = vnode.el = vnode.anchor = createTextNode()
6766
container.insertBefore(selfAnchor, anchor)
6867
}
6968
const prev = currentInstance
@@ -91,6 +90,12 @@ const vaporInteropImpl: Omit<
9190
))
9291
instance.rawPropsRef = propsRef
9392
instance.rawSlotsRef = slotsRef
93+
if (isHydrating) {
94+
// insert self anchor after hydration completed to avoid mismatching
95+
;(instance.m || (instance.m = [])).push(() => {
96+
container.insertBefore(selfAnchor, anchor)
97+
})
98+
}
9499
mountComponent(instance, container, selfAnchor)
95100
simpleSetCurrentInstance(prev)
96101
return instance
@@ -113,7 +118,7 @@ const vaporInteropImpl: Omit<
113118
} else if (vnode.vb) {
114119
remove(vnode.vb, container)
115120
}
116-
if (vnode.anchor) remove(vnode.anchor as Node, container)
121+
remove(vnode.anchor as Node, container)
117122
},
118123

119124
/**

0 commit comments

Comments
 (0)