@@ -275,11 +275,12 @@ export class ProtoView {
275275 }
276276 var viewNodes ;
277277 if ( this . isTemplateElement ) {
278- var childNodes = rootElementClone . content . childNodes ;
279- // Note: An explicit loop is the fastes way to convert a DOM array into a JS array!
280- viewNodes = ListWrapper . createFixedSize ( childNodes . length ) ;
281- for ( var i = 0 ; i < childNodes . length ; i ++ ) {
282- viewNodes [ i ] = childNodes [ i ] ;
278+ var childNode = DOM . firstChild ( rootElementClone . content ) ;
279+ viewNodes = [ ] ; // TODO(perf): Should be fixed size, since we could pre-compute in in ProtoView
280+ // Note: An explicit loop is the fastest way to convert a DOM array into a JS array!
281+ while ( childNode != null ) {
282+ ListWrapper . push ( viewNodes , childNode ) ;
283+ childNode = DOM . nextSibling ( childNode ) ;
283284 }
284285 } else {
285286 viewNodes = [ rootElementClone ] ;
@@ -338,9 +339,12 @@ export class ProtoView {
338339 // textNodes
339340 var textNodeIndices = binder . textNodeIndices ;
340341 if ( isPresent ( textNodeIndices ) ) {
341- var childNodes = DOM . templateAwareRoot ( element ) . childNodes ;
342- for ( var j = 0 ; j < textNodeIndices . length ; j ++ ) {
343- ListWrapper . push ( textNodes , childNodes [ textNodeIndices [ j ] ] ) ;
342+ var childNode = DOM . firstChild ( DOM . templateAwareRoot ( element ) ) ;
343+ for ( var j = 0 , k = 0 ; j < textNodeIndices . length ; j ++ ) {
344+ for ( var index = textNodeIndices [ j ] ; k < index ; k ++ ) {
345+ childNode = DOM . nextSibling ( childNode ) ;
346+ }
347+ ListWrapper . push ( textNodes , childNode ) ;
344348 }
345349 }
346350
0 commit comments