chore: delay insert self anchor during hydration
ci / test (push) Waiting to run Details
ci / continuous-release (push) Waiting to run Details

This commit is contained in:
daiwei 2025-09-29 08:25:37 +08:00
parent 12e41691c3
commit 0436ceac77
2 changed files with 7 additions and 12 deletions

View File

@ -659,17 +659,6 @@ export function createHydrationFunctions(
) )
} }
} }
// the server output does not contain blank text nodes. It appears here that
// it is a dynamically inserted anchor, and needs to be skipped.
// e.g. vaporInteropImpl.mount() > selfAnchor
if (
node &&
node.nodeType === DOMNodeTypes.TEXT &&
!(node as Text).data.trim()
) {
node = nextSibling(node)
}
return node return node
} }

View File

@ -24,6 +24,7 @@ import {
isRef, isRef,
isVNode, isVNode,
onScopeDispose, onScopeDispose,
queuePostFlushCb,
renderSlot, renderSlot,
setTransitionHooks as setVNodeTransitionHooks, setTransitionHooks as setVNodeTransitionHooks,
shallowReactive, shallowReactive,
@ -74,7 +75,12 @@ const vaporInteropImpl: Omit<
> = { > = {
mount(vnode, container, anchor, parentComponent) { mount(vnode, container, anchor, parentComponent) {
let selfAnchor = (vnode.el = vnode.anchor = createTextNode()) let selfAnchor = (vnode.el = vnode.anchor = createTextNode())
if (isHydrating) {
// avoid vdom hydration children mismatch by the selfAnchor, delay its insertion
queuePostFlushCb(() => container.insertBefore(selfAnchor, anchor))
} else {
container.insertBefore(selfAnchor, anchor) container.insertBefore(selfAnchor, anchor)
}
const prev = currentInstance const prev = currentInstance
simpleSetCurrentInstance(parentComponent) simpleSetCurrentInstance(parentComponent)