feat: proper static tree skip
This commit is contained in:
parent
6e424397d1
commit
fc5aa6d0be
@ -477,7 +477,18 @@ export function createRenderer(options: RendererOptions) {
|
|||||||
contextVNode: MountedVNode | null,
|
contextVNode: MountedVNode | null,
|
||||||
isSVG: boolean
|
isSVG: boolean
|
||||||
) {
|
) {
|
||||||
const { flags, tag } = nextVNode
|
const { flags, tag, clonedFrom } = nextVNode
|
||||||
|
|
||||||
|
// cloned vnodes pointing to the same original.
|
||||||
|
// these are hoisted static trees so just skip entirely
|
||||||
|
if (
|
||||||
|
clonedFrom !== null &&
|
||||||
|
(clonedFrom === prevVNode || clonedFrom === prevVNode.clonedFrom)
|
||||||
|
) {
|
||||||
|
nextVNode.el = prevVNode.el
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
isSVG = isSVG || (flags & VNodeFlags.ELEMENT_SVG) > 0
|
isSVG = isSVG || (flags & VNodeFlags.ELEMENT_SVG) > 0
|
||||||
|
|
||||||
if (prevVNode.tag !== tag) {
|
if (prevVNode.tag !== tag) {
|
||||||
|
@ -43,6 +43,8 @@ export interface VNode {
|
|||||||
// a consistent handle so that a functional component can be identified
|
// a consistent handle so that a functional component can be identified
|
||||||
// by the scheduler
|
// by the scheduler
|
||||||
handle: FunctionalHandle | null
|
handle: FunctionalHandle | null
|
||||||
|
// only on cloned vnodes, points to the original cloned vnode
|
||||||
|
clonedFrom: VNode | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MountedVNode extends VNode {
|
export interface MountedVNode extends VNode {
|
||||||
@ -99,7 +101,8 @@ export function createVNode(
|
|||||||
el: null,
|
el: null,
|
||||||
parentVNode: null,
|
parentVNode: null,
|
||||||
contextVNode: null,
|
contextVNode: null,
|
||||||
handle: null
|
handle: null,
|
||||||
|
clonedFrom: null
|
||||||
}
|
}
|
||||||
if (childFlags === ChildrenFlags.UNKNOWN_CHILDREN) {
|
if (childFlags === ChildrenFlags.UNKNOWN_CHILDREN) {
|
||||||
normalizeChildren(vnode, children)
|
normalizeChildren(vnode, children)
|
||||||
@ -339,7 +342,7 @@ export function cloneVNode(vnode: VNode, extraData?: VNodeData): VNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return createVNode(
|
const cloned = createVNode(
|
||||||
flags,
|
flags,
|
||||||
vnode.tag,
|
vnode.tag,
|
||||||
clonedData,
|
clonedData,
|
||||||
@ -349,6 +352,8 @@ export function cloneVNode(vnode: VNode, extraData?: VNodeData): VNode {
|
|||||||
vnode.ref,
|
vnode.ref,
|
||||||
vnode.slots
|
vnode.slots
|
||||||
)
|
)
|
||||||
|
cloned.clonedFrom = vnode.clonedFrom || vnode
|
||||||
|
return cloned
|
||||||
} else if (flags & VNodeFlags.TEXT) {
|
} else if (flags & VNodeFlags.TEXT) {
|
||||||
return createTextVNode(vnode.children as string)
|
return createTextVNode(vnode.children as string)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user