mirror of https://github.com/vuejs/core.git
perf: don't initialize hydration state if no anchor
This commit is contained in:
parent
dd86809806
commit
2f6ac67c6a
|
@ -30,18 +30,23 @@ export function setInsertionState(
|
||||||
anchor?: Node | 0 | null | number,
|
anchor?: Node | 0 | null | number,
|
||||||
): void {
|
): void {
|
||||||
insertionParent = parent
|
insertionParent = parent
|
||||||
if (isHydrating) {
|
|
||||||
initializeHydrationState(anchor, parent)
|
if (anchor !== undefined) {
|
||||||
|
if (isHydrating) {
|
||||||
|
insertionAnchor = anchor as Node
|
||||||
|
initializeHydrationState(parent)
|
||||||
|
} else {
|
||||||
|
// special handling append anchor value to null
|
||||||
|
insertionAnchor =
|
||||||
|
typeof anchor === 'number' && anchor > 0 ? null : (anchor as Node)
|
||||||
|
cacheTemplateChildren(parent)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cacheTemplateChildren(anchor, parent)
|
insertionAnchor = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeHydrationState(
|
function initializeHydrationState(parent: ParentNode) {
|
||||||
anchor: number | Node | null | undefined,
|
|
||||||
parent: ParentNode,
|
|
||||||
) {
|
|
||||||
insertionAnchor = anchor as Node
|
|
||||||
if (!hydrationStateCache.has(parent)) {
|
if (!hydrationStateCache.has(parent)) {
|
||||||
const childNodes = parent.childNodes
|
const childNodes = parent.childNodes
|
||||||
const len = childNodes.length
|
const len = childNodes.length
|
||||||
|
@ -90,14 +95,7 @@ function initializeHydrationState(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cacheTemplateChildren(
|
function cacheTemplateChildren(parent: InsertionParent) {
|
||||||
anchor: number | Node | null | undefined,
|
|
||||||
parent: InsertionParent,
|
|
||||||
) {
|
|
||||||
// special handling append anchor value to null
|
|
||||||
insertionAnchor =
|
|
||||||
typeof anchor === 'number' && anchor > 0 ? null : (anchor as Node)
|
|
||||||
|
|
||||||
if (!parent.$children) {
|
if (!parent.$children) {
|
||||||
const nodes = parent.childNodes
|
const nodes = parent.childNodes
|
||||||
const len = nodes.length
|
const len = nodes.length
|
||||||
|
|
Loading…
Reference in New Issue