contextVNode: MountedVNode | null,
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
if (prevVNode.tag !== tag) {
// a consistent handle so that a functional component can be identified
// by the scheduler
handle: FunctionalHandle | null
+ // only on cloned vnodes, points to the original cloned vnode
+ clonedFrom: VNode | null
}
export interface MountedVNode extends VNode {
el: null,
parentVNode: null,
contextVNode: null,
- handle: null
+ handle: null,
+ clonedFrom: null
}
if (childFlags === ChildrenFlags.UNKNOWN_CHILDREN) {
normalizeChildren(vnode, children)
}
}
}
- return createVNode(
+ const cloned = createVNode(
flags,
vnode.tag,
clonedData,
vnode.ref,
vnode.slots
)
+ cloned.clonedFrom = vnode.clonedFrom || vnode
+ return cloned
} else if (flags & VNodeFlags.TEXT) {
return createTextVNode(vnode.children as string)
} else {