mirror of https://github.com/vuejs/core.git
fix(hydration): improve parent sibling lookup
This commit is contained in:
parent
761b1617a7
commit
1b0818bcde
|
@ -20,10 +20,16 @@ export function setCurrentHydrationNode(node: Node | null): void {
|
||||||
currentHydrationNode = node
|
currentHydrationNode = node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findParentSibling(n: Node): Node | null {
|
||||||
|
if (!n.parentNode) return null
|
||||||
|
const next = n.parentNode.nextSibling
|
||||||
|
return next ? next : findParentSibling(n.parentNode)
|
||||||
|
}
|
||||||
|
|
||||||
export function advanceHydrationNode(node: Node): void {
|
export function advanceHydrationNode(node: Node): void {
|
||||||
setCurrentHydrationNode(
|
// if no next sibling, find the next node in the parent chain
|
||||||
node.nextSibling || (node.parentNode ? node.parentNode.nextSibling : null),
|
const next = node.nextSibling || findParentSibling(node)
|
||||||
)
|
if (next) setCurrentHydrationNode(next)
|
||||||
}
|
}
|
||||||
|
|
||||||
let isOptimized = false
|
let isOptimized = false
|
||||||
|
|
Loading…
Reference in New Issue