@@ -1067,40 +1067,39 @@ namespace Private {
10671067 function createDOMNode ( node : VirtualNode , host : HTMLElement | null , before : Node | null ) : HTMLElement | Text ;
10681068 export
10691069 function createDOMNode ( node : VirtualNode ) : HTMLElement | Text {
1070- const host = arguments [ 1 ] || null ;
1070+ let host = arguments [ 1 ] || null ;
10711071 const before = arguments [ 2 ] || null ;
10721072
1073- if ( host ) {
1074- if ( node . type === 'passthru' ) {
1073+ if ( node . type === 'passthru' ) {
1074+ if ( host ) {
10751075 // TODO: figure out how to do an "insert before" with a passthru node
10761076 node . render ( host ) ;
10771077 } else {
1078- host . insertBefore ( createDOMNode ( node ) , before ) ;
1079- }
1080-
1081- return host ;
1082- } else {
1083- // Create a text node for a virtual text node.
1084- if ( node . type === 'text' ) {
1085- return document . createTextNode ( node . content ) ;
1086- } else if ( node . type === 'passthru' ) {
10871078 throw new Error ( "createDOMNode should not be called with only one argument on vdom nodes of type === 'passthru'" ) ;
10881079 }
1080+ } else {
1081+ if ( host ) {
1082+ host . insertBefore ( createDOMNode ( node ) , before ) ;
1083+ } else {
1084+ // Create a text node for a virtual text node.
1085+ if ( node . type === 'text' ) {
1086+ return document . createTextNode ( node . content ) ;
1087+ }
10891088
1090- // Create the HTML element with the specified tag.
1091- let element = document . createElement ( node . tag ) ;
1089+ // Create the HTML element with the specified tag.
1090+ host = document . createElement ( node . tag ) ;
10921091
1093- // Add the attributes for the new element.
1094- addAttrs ( element , node . attrs ) ;
1092+ // Add the attributes for the new element.
1093+ addAttrs ( host , node . attrs ) ;
10951094
1096- // Recursively populate the element with child content.
1097- for ( let i = 0 , n = node . children . length ; i < n ; ++ i ) {
1098- createDOMNode ( node . children [ i ] , element ) ;
1095+ // Recursively populate the element with child content.
1096+ for ( let i = 0 , n = node . children . length ; i < n ; ++ i ) {
1097+ createDOMNode ( node . children [ i ] , host ) ;
1098+ }
10991099 }
1100-
1101- // Return the populated element.
1102- return element ;
11031100 }
1101+
1102+ return host ;
11041103 }
11051104
11061105 /**
0 commit comments