mirror of https://github.com/vuejs/core.git
perf: replace $lastLogicalChild with vfor end anchor
This commit is contained in:
parent
a4d7e70db8
commit
f567f59fe7
|
@ -35,6 +35,7 @@ import {
|
||||||
} from './dom/hydration'
|
} from './dom/hydration'
|
||||||
import { ForFragment, VaporFragment, findLastChild } from './fragment'
|
import { ForFragment, VaporFragment, findLastChild } from './fragment'
|
||||||
import {
|
import {
|
||||||
|
type ChildItem,
|
||||||
insertionAnchor,
|
insertionAnchor,
|
||||||
insertionParent,
|
insertionParent,
|
||||||
resetInsertionState,
|
resetInsertionState,
|
||||||
|
@ -150,6 +151,15 @@ export const createFor = (
|
||||||
if (!parentAnchor || (parentAnchor && !isComment(parentAnchor, ']'))) {
|
if (!parentAnchor || (parentAnchor && !isComment(parentAnchor, ']'))) {
|
||||||
throw new Error(`v-for fragment anchor node was not found.`)
|
throw new Error(`v-for fragment anchor node was not found.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $lastLogicalChild is the fragment start anchor; replacing it with end anchor
|
||||||
|
// can avoid the call to locateEndAnchor within locateChildByLogicalIndex
|
||||||
|
if (_insertionParent && _insertionParent!.$lastLogicalChild) {
|
||||||
|
;(parentAnchor as any as ChildItem).$idx = (
|
||||||
|
_insertionParent!.$lastLogicalChild as ChildItem
|
||||||
|
).$idx
|
||||||
|
_insertionParent.$lastLogicalChild = parentAnchor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
parent = parent || parentAnchor!.parentNode
|
parent = parent || parentAnchor!.parentNode
|
||||||
|
|
Loading…
Reference in New Issue