@@ -221,6 +221,28 @@ describe('reactify', () => {
221221
222222 dispose ( )
223223 } )
224+
225+ it ( 'uses a custom host tag name when configured' , async ( ) => {
226+ const CustomHost = reactify (
227+ ( { value } : { value : string } ) => React . createElement ( 'span' , { id : 'custom-host' } , value ) ,
228+ {
229+ tagName : 'section' ,
230+ } ,
231+ )
232+
233+ const container = document . createElement ( 'div' )
234+ document . body . appendChild ( container )
235+
236+ const dispose = render ( ( ) => ( { type : CustomHost , props : { value : 'ok' } } ) , container )
237+ await tick ( )
238+
239+ const host = container . querySelector ( '[data-fict-react-host]' ) as HTMLElement | null
240+ expect ( host ) . not . toBeNull ( )
241+ expect ( host ?. tagName ) . toBe ( 'SECTION' )
242+ expect ( container . querySelector ( '#custom-host' ) ?. textContent ) . toBe ( 'ok' )
243+
244+ dispose ( )
245+ } )
224246} )
225247
226248describe ( 'ReactIsland' , ( ) => {
@@ -270,4 +292,33 @@ describe('ReactIsland', () => {
270292
271293 dispose ( )
272294 } )
295+
296+ it ( 'supports custom host tag name on ReactIsland' , async ( ) => {
297+ function Label ( props : { text : string } ) {
298+ return React . createElement ( 'p' , { id : 'island-custom-host' } , props . text )
299+ }
300+
301+ const container = document . createElement ( 'div' )
302+ document . body . appendChild ( container )
303+
304+ const dispose = render (
305+ ( ) => ( {
306+ type : ReactIsland ,
307+ props : {
308+ component : Label ,
309+ tagName : 'article' ,
310+ props : { text : 'custom' } ,
311+ } ,
312+ } ) ,
313+ container ,
314+ )
315+ await tick ( )
316+
317+ const host = container . querySelector ( '[data-fict-react-host]' ) as HTMLElement | null
318+ expect ( host ) . not . toBeNull ( )
319+ expect ( host ?. tagName ) . toBe ( 'ARTICLE' )
320+ expect ( container . querySelector ( '#island-custom-host' ) ?. textContent ) . toBe ( 'custom' )
321+
322+ dispose ( )
323+ } )
273324} )
0 commit comments