@@ -40,6 +40,17 @@ describe('render', () => {
4040 render ( main ( child ( 'Goodbye' ) ) , surface )
4141 expect ( surface . innerHTML ) . to . equal ( '<div><span>Goodbye</span></div>' )
4242 } )
43+
44+ it ( 'can nest document fragments and text nodes' , ( ) => {
45+ const main = frag => html `< span > ${ frag } </ span > `
46+ const fragment = document . createDocumentFragment ( )
47+ fragment . append ( new Text ( 'Hello World' ) )
48+ render ( main ( fragment ) , surface )
49+ expect ( surface . innerHTML ) . to . equal ( '<span>Hello World</span>' )
50+ fragment . append ( document . createTextNode ( 'Hello Universe!' ) )
51+ render ( main ( fragment ) , surface )
52+ expect ( surface . innerHTML ) . to . equal ( '<span>Hello Universe!</span>' )
53+ } )
4354 } )
4455
4556 describe ( 'iterables' , ( ) => {
@@ -51,6 +62,34 @@ describe('render', () => {
5162 expect ( surface . innerHTML ) . to . equal ( '<div>fourfivesix</div>' )
5263 } )
5364
65+ it ( 'supports iterables of Sub Templates with text nodes' , ( ) => {
66+ const main = list => html `< div > ${ list } </ div > `
67+ let fragments = [ 'one' , 'two' , 'three' ] . map ( text => html `${ text } ` )
68+ render ( main ( fragments ) , surface )
69+ expect ( surface . innerHTML ) . to . equal ( '<div>onetwothree</div>' )
70+ fragments = [ 'four' , 'five' , 'six' ] . map ( text => html `${ text } ` )
71+ render ( main ( fragments ) , surface )
72+ expect ( surface . innerHTML ) . to . equal ( '<div>fourfivesix</div>' )
73+ } )
74+
75+ it ( 'supports iterables of fragments with text nodes' , ( ) => {
76+ const main = list => html `< div > ${ list } </ div > `
77+ let fragments = [ 'one' , 'two' , 'three' ] . map ( text => {
78+ const fragment = document . createDocumentFragment ( )
79+ fragment . append ( new Text ( text ) )
80+ return fragment
81+ } )
82+ render ( main ( fragments ) , surface )
83+ expect ( surface . innerHTML ) . to . equal ( '<div>onetwothree</div>' )
84+ fragments = [ 'four' , 'five' , 'six' ] . map ( text => {
85+ const fragment = document . createDocumentFragment ( )
86+ fragment . append ( new Text ( text ) )
87+ return fragment
88+ } )
89+ render ( main ( fragments ) , surface )
90+ expect ( surface . innerHTML ) . to . equal ( '<div>fourfivesix</div>' )
91+ } )
92+
5493 it ( 'supports other strings iterables in nodes' , ( ) => {
5594 const main = list => html `< div > ${ list } </ div > `
5695 render ( main ( new Set ( [ 'one' , 'two' , 'three' ] ) ) , surface )
0 commit comments