This repository was archived by the owner on Jan 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ function processSubTemplate(part: TemplatePart, value: unknown): boolean {
1919
2020function processDocumentFragment ( part : TemplatePart , value : unknown ) : boolean {
2121 if ( value instanceof DocumentFragment && part instanceof NodeTemplatePart ) {
22- part . replace ( ( value as unknown ) as ChildNode )
22+ if ( value . childNodes . length ) part . replace ( ... value . childNodes )
2323 return true
2424 }
2525 return false
Original file line number Diff line number Diff line change @@ -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' , ( ) => {
You can’t perform that action at this time.
0 commit comments