@@ -50,7 +50,7 @@ export class TemplateHelper {
5050 const div = document . createElement ( 'div' ) ;
5151 // tslint:disable-next-line: prefer-for-of
5252 for ( let i = 0 ; i < template . childNodes . length ; i ++ ) {
53- div . appendChild ( template . childNodes [ i ] . cloneNode ( true ) ) ;
53+ div . appendChild ( this . simpleCloneNode ( template . childNodes [ i ] ) ) ;
5454 }
5555 rendered = this . renderNode ( div , root , context , additionalContext ) ;
5656 }
@@ -62,6 +62,26 @@ export class TemplateHelper {
6262
6363 private static _expression = / { { + \s * [ $ \w \. ( ) \[ \] ] + \s * } } + / g;
6464
65+ // simple implementation of deep cloneNode
66+ // required for nested templates in polyfilled browsers
67+ private static simpleCloneNode ( node : ChildNode ) {
68+ if ( ! node ) {
69+ return null ;
70+ }
71+
72+ const clone = node . cloneNode ( false ) ;
73+
74+ // tslint:disable-next-line:prefer-for-of
75+ for ( let i = 0 ; i < node . childNodes . length ; i ++ ) {
76+ const childClone = this . simpleCloneNode ( node . childNodes [ i ] ) ;
77+ if ( childClone ) {
78+ clone . appendChild ( childClone ) ;
79+ }
80+ }
81+
82+ return clone ;
83+ }
84+
6585 private static expandExpressionsAsString ( str : string , context : object , additionalContext : object ) {
6686 return str . replace ( this . _expression , match => {
6787 const value = this . evalInContext ( this . trimExpression ( match ) , { ...context , ...additionalContext } ) ;
0 commit comments