File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -634,12 +634,6 @@ const walker = d.createTreeWalker(
634634 false
635635) ;
636636
637- // A node that we use to "park" the above TreeWalker at. This prevents the
638- // TreeWalker from holding onto the DOM tree that we're processing after we're
639- // done. This is necessary because we keep one TreeWalker instance for all tree
640- // walks as a performance optimization.
641- const walkerParkingNode = createMarker ( ) ;
642-
643637let sanitizerFactoryInternal : SanitizerFactory = noopSanitizer ;
644638
645639//
@@ -1011,7 +1005,9 @@ class Template {
10111005 }
10121006 nodeIndex ++ ;
10131007 }
1014- walker . currentNode = walkerParkingNode ;
1008+ // We could set walker.currentNode to another node here to prevent a memory
1009+ // leak, but every time we prepare a template, we immediately render it
1010+ // and re-use the walker in new TemplateInstance._clone().
10151011 debugLogEvent ?.( {
10161012 kind : 'template prep' ,
10171013 template : this ,
@@ -1162,7 +1158,10 @@ class TemplateInstance implements Disconnectable {
11621158 nodeIndex ++ ;
11631159 }
11641160 }
1165- walker . currentNode = walkerParkingNode ;
1161+ // We need to set the currentNode away from the cloned tree so that we
1162+ // don't hold onto the tree even if the tree is detached and should be
1163+ // freed.
1164+ walker . currentNode = d ;
11661165 return fragment ;
11671166 }
11681167
You can’t perform that action at this time.
0 commit comments