perf: improve static content insertion perf

Especially on multiple insertions of the same static node.

fix #3090
This commit is contained in:
Evan You
2021-06-21 14:34:08 -04:00
parent be1e42eb92
commit 4de5d24aa7
3 changed files with 151 additions and 21 deletions

View File

@@ -141,7 +141,8 @@ export interface RendererOptions<
content: string,
parent: HostElement,
anchor: HostNode | null,
isSVG: boolean
isSVG: boolean,
cached?: [HostNode, HostNode | null] | null
): HostElement[]
}
@@ -635,7 +636,11 @@ function baseCreateRenderer(
n2.children as string,
container,
anchor,
isSVG
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.el && [n2.el, n2.anchor]
)
}