@@ -4,7 +4,7 @@ export const svgNS = 'http://www.w3.org/2000/svg'
44
55const doc = ( typeof document !== 'undefined' ? document : null ) as Document
66
7- const staticTemplateCache = new Map < string , DocumentFragment > ( )
7+ const templateContainer = doc && doc . createElement ( 'template' )
88
99export const nodeOps : Omit < RendererOptions < Node , Element > , 'patchProp' > = {
1010 insert : ( child , parent , anchor ) => {
@@ -73,14 +73,19 @@ export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
7373 // Reason: innerHTML.
7474 // Static content here can only come from compiled templates.
7575 // As long as the user only uses trusted templates, this is safe.
76- insertStaticContent ( content , parent , anchor , isSVG ) {
76+ insertStaticContent ( content , parent , anchor , isSVG , start , end ) {
7777 // <parent> before | first ... last | anchor </parent>
7878 const before = anchor ? anchor . previousSibling : parent . lastChild
79- let template = staticTemplateCache . get ( content )
80- if ( ! template ) {
81- const t = doc . createElement ( 'template' )
82- t . innerHTML = isSVG ? `<svg>${ content } </svg>` : content
83- template = t . content
79+ if ( start && end ) {
80+ // cached
81+ while ( true ) {
82+ parent . insertBefore ( start ! . cloneNode ( true ) , anchor )
83+ if ( start === end || ! ( start = start ! . nextSibling ) ) break
84+ }
85+ } else {
86+ // fresh insert
87+ templateContainer . innerHTML = isSVG ? `<svg>${ content } </svg>` : content
88+ const template = templateContainer . content
8489 if ( isSVG ) {
8590 // remove outer svg wrapper
8691 const wrapper = template . firstChild !
@@ -89,9 +94,8 @@ export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
8994 }
9095 template . removeChild ( wrapper )
9196 }
92- staticTemplateCache . set ( content , template )
97+ parent . insertBefore ( template , anchor )
9398 }
94- parent . insertBefore ( template . cloneNode ( true ) , anchor )
9599 return [
96100 // first
97101 before ? before . nextSibling ! : parent . firstChild ! ,
0 commit comments