@@ -1324,6 +1324,84 @@ describe('SSR hydration', () => {
1324
1324
resolve ( { } )
1325
1325
} )
1326
1326
1327
+ //#12362
1328
+ test ( 'nested async wrapper' , async ( ) => {
1329
+ const Toggle = defineAsyncComponent (
1330
+ ( ) =>
1331
+ new Promise ( r => {
1332
+ r (
1333
+ defineComponent ( {
1334
+ setup ( _ , { slots } ) {
1335
+ const show = ref ( false )
1336
+ onMounted ( ( ) => {
1337
+ nextTick ( ( ) => {
1338
+ show . value = true
1339
+ } )
1340
+ } )
1341
+ return ( ) =>
1342
+ withDirectives (
1343
+ h ( 'div' , null , [ renderSlot ( slots , 'default' ) ] ) ,
1344
+ [ [ vShow , show . value ] ] ,
1345
+ )
1346
+ } ,
1347
+ } ) as any ,
1348
+ )
1349
+ } ) ,
1350
+ )
1351
+
1352
+ const Wrapper = defineAsyncComponent ( ( ) => {
1353
+ return new Promise ( r => {
1354
+ r (
1355
+ defineComponent ( {
1356
+ render ( this : any ) {
1357
+ return renderSlot ( this . $slots , 'default' )
1358
+ } ,
1359
+ } ) as any ,
1360
+ )
1361
+ } )
1362
+ } )
1363
+
1364
+ const count = ref ( 0 )
1365
+ const fn = vi . fn ( )
1366
+ const Child = {
1367
+ setup ( ) {
1368
+ onMounted ( ( ) => {
1369
+ fn ( )
1370
+ count . value ++
1371
+ } )
1372
+ return ( ) => h ( 'div' , count . value )
1373
+ } ,
1374
+ }
1375
+
1376
+ const App = {
1377
+ render ( ) {
1378
+ return h ( Toggle , null , {
1379
+ default : ( ) =>
1380
+ h ( Wrapper , null , {
1381
+ default : ( ) =>
1382
+ h ( Wrapper , null , {
1383
+ default : ( ) => h ( Child ) ,
1384
+ } ) ,
1385
+ } ) ,
1386
+ } )
1387
+ } ,
1388
+ }
1389
+
1390
+ const root = document . createElement ( 'div' )
1391
+ root . innerHTML = await renderToString ( h ( App ) )
1392
+ expect ( root . innerHTML ) . toMatchInlineSnapshot (
1393
+ `"<div style="display:none;"><!--[--><!--[--><!--[--><div>0</div><!--]--><!--]--><!--]--></div>"` ,
1394
+ )
1395
+
1396
+ createSSRApp ( App ) . mount ( root )
1397
+ await nextTick ( )
1398
+ await nextTick ( )
1399
+ expect ( root . innerHTML ) . toMatchInlineSnapshot (
1400
+ `"<div style=""><!--[--><!--[--><!--[--><div>1</div><!--]--><!--]--><!--]--></div>"` ,
1401
+ )
1402
+ expect ( fn ) . toBeCalledTimes ( 1 )
1403
+ } )
1404
+
1327
1405
test ( 'unmount async wrapper before load (fragment)' , async ( ) => {
1328
1406
let resolve : any
1329
1407
const AsyncComp = defineAsyncComponent (
0 commit comments