refactor: simplify static content insertion
This commit is contained in:
@@ -142,9 +142,8 @@ export interface RendererOptions<
|
||||
content: string,
|
||||
parent: HostElement,
|
||||
anchor: HostNode | null,
|
||||
isSVG: boolean,
|
||||
cached?: HostNode[] | null
|
||||
): HostElement[]
|
||||
isSVG: boolean
|
||||
): [HostNode, HostNode]
|
||||
}
|
||||
|
||||
// Renderer Node can technically be any object in the context of core renderer
|
||||
@@ -633,22 +632,12 @@ function baseCreateRenderer(
|
||||
) => {
|
||||
// static nodes are only present when used with compiler-dom/runtime-dom
|
||||
// which guarantees presence of hostInsertStaticContent.
|
||||
const nodes = hostInsertStaticContent!(
|
||||
;[n2.el, n2.anchor] = hostInsertStaticContent!(
|
||||
n2.children as string,
|
||||
container,
|
||||
anchor,
|
||||
isSVG,
|
||||
// pass cached nodes if the static node is being mounted multiple times
|
||||
// so that runtime-dom can simply cloneNode() instead of inserting new
|
||||
// HTML
|
||||
n2.staticCache
|
||||
isSVG
|
||||
)
|
||||
// first mount - this is the orignal hoisted vnode. cache nodes.
|
||||
if (!n2.el) {
|
||||
n2.staticCache = nodes
|
||||
}
|
||||
n2.el = nodes[0]
|
||||
n2.anchor = nodes[nodes.length - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -168,7 +168,6 @@ export interface VNode<
|
||||
target: HostElement | null // teleport target
|
||||
targetAnchor: HostNode | null // teleport target anchor
|
||||
staticCount?: number // number of elements contained in a static vnode
|
||||
staticCache?: HostNode[] // cache of parsed static nodes for faster repeated insertions
|
||||
|
||||
// suspense
|
||||
suspense: SuspenseBoundary | null
|
||||
@@ -521,7 +520,6 @@ export function cloneVNode<T, U>(
|
||||
target: vnode.target,
|
||||
targetAnchor: vnode.targetAnchor,
|
||||
staticCount: vnode.staticCount,
|
||||
staticCache: vnode.staticCache,
|
||||
shapeFlag: vnode.shapeFlag,
|
||||
// if the vnode is cloned with extra props, we can no longer assume its
|
||||
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
||||
|
||||
Reference in New Issue
Block a user