@@ -366,6 +366,35 @@ describe('SSR hydration', () => {
366
366
)
367
367
} )
368
368
369
+ test ( 'Teleport (as component root)' , ( ) => {
370
+ const teleportContainer = document . createElement ( 'div' )
371
+ teleportContainer . id = 'teleport4'
372
+ teleportContainer . innerHTML = `hello<!---->`
373
+ document . body . appendChild ( teleportContainer )
374
+
375
+ const wrapper = {
376
+ render ( ) {
377
+ return h ( Teleport , { to : '#teleport4' } , [ 'hello' ] )
378
+ }
379
+ }
380
+
381
+ const { vnode, container } = mountWithHydration (
382
+ '<div><!--teleport start--><!--teleport end--><div></div></div>' ,
383
+ ( ) => h ( 'div' , [ h ( wrapper ) , h ( 'div' ) ] )
384
+ )
385
+ expect ( vnode . el ) . toBe ( container . firstChild )
386
+ // component el
387
+ const wrapperVNode = ( vnode as any ) . children [ 0 ]
388
+ const tpStart = container . firstChild ?. firstChild
389
+ const tpEnd = tpStart ?. nextSibling
390
+ expect ( wrapperVNode . el ) . toBe ( tpStart )
391
+ expect ( wrapperVNode . component . subTree . el ) . toBe ( tpStart )
392
+ expect ( wrapperVNode . component . subTree . anchor ) . toBe ( tpEnd )
393
+ // next node hydrate properly
394
+ const nextVNode = ( vnode as any ) . children [ 1 ]
395
+ expect ( nextVNode . el ) . toBe ( container . firstChild ?. lastChild )
396
+ } )
397
+
369
398
// compile SSR + client render fn from the same template & hydrate
370
399
test ( 'full compiler integration' , async ( ) => {
371
400
const mounted : string [ ] = [ ]
0 commit comments