@@ -2360,6 +2360,101 @@ describe('Suspense', () => {
23602360 )
23612361 } )
23622362
2363+ // #14173
2364+ test ( 'renders multiple async component wrappers in Suspense with v-for and updates on items change' , async ( ) => {
2365+ const CompAsyncSetup = defineAsyncComponent ( {
2366+ props : [ 'item' , 'id' ] ,
2367+ render ( ctx : any ) {
2368+ return h ( 'div' , ctx . id + '--' + ctx . item . name )
2369+ } ,
2370+ } )
2371+ const items = ref ( [
2372+ { id : 1 , name : '111' } ,
2373+ { id : 2 , name : '222' } ,
2374+ { id : 3 , name : '333' } ,
2375+ ] )
2376+ const Comp = {
2377+ props : [ 'id' ] ,
2378+ setup ( props : any ) {
2379+ return ( ) =>
2380+ h ( Suspense , null , {
2381+ default : ( ) =>
2382+ h (
2383+ Fragment ,
2384+ null ,
2385+ items . value . map ( item =>
2386+ h ( CompAsyncSetup , {
2387+ item,
2388+ key : item . id ,
2389+ id : 'foo:' + props . id ,
2390+ } ) ,
2391+ ) ,
2392+ ) ,
2393+ } )
2394+ } ,
2395+ }
2396+
2397+ const CompAsyncWrapper = defineAsyncComponent ( {
2398+ props : [ 'id' ] ,
2399+ render ( ctx : any ) {
2400+ return h ( Comp , { id : ctx . id } )
2401+ } ,
2402+ } )
2403+ const CompWrapper = defineComponent ( {
2404+ props : [ 'id' ] ,
2405+ render ( ctx : any ) {
2406+ return h ( CompAsyncWrapper , { id : ctx . id } )
2407+ } ,
2408+ } )
2409+ const list = ref ( [ { id : 1 } , { id : 2 } , { id : 3 } ] )
2410+
2411+ const App = {
2412+ setup ( ) {
2413+ return ( ) =>
2414+ h ( Suspense , null , {
2415+ default : ( ) =>
2416+ h (
2417+ Fragment ,
2418+ null ,
2419+ list . value . map ( item =>
2420+ h ( CompWrapper , { id : item . id , key : item . id } ) ,
2421+ ) ,
2422+ ) ,
2423+ } )
2424+ } ,
2425+ }
2426+
2427+ const root = nodeOps . createElement ( 'div' )
2428+ render ( h ( App ) , root )
2429+ await nextTick ( )
2430+ await Promise . all ( deps )
2431+ await Promise . all ( deps )
2432+
2433+ expect ( serializeInner ( root ) ) . toBe (
2434+ `<div>foo:1--111</div><div>foo:1--222</div><div>foo:1--333</div><div>foo:2--111</div><div>foo:2--222</div><div>foo:2--333</div><div>foo:3--111</div><div>foo:3--222</div><div>foo:3--333</div>` ,
2435+ )
2436+
2437+ list . value = [ { id : 4 } , { id : 5 } , { id : 6 } ]
2438+ await nextTick ( )
2439+ await Promise . all ( deps )
2440+ await Promise . all ( deps )
2441+ expect ( serializeInner ( root ) ) . toBe (
2442+ `<div>foo:4--111</div><div>foo:4--222</div><div>foo:4--333</div><div>foo:5--111</div><div>foo:5--222</div><div>foo:5--333</div><div>foo:6--111</div><div>foo:6--222</div><div>foo:6--333</div>` ,
2443+ )
2444+
2445+ items . value = [
2446+ { id : 4 , name : '444' } ,
2447+ { id : 5 , name : '555' } ,
2448+ { id : 6 , name : '666' } ,
2449+ ]
2450+ await nextTick ( )
2451+ await Promise . all ( deps )
2452+ await Promise . all ( deps )
2453+ expect ( serializeInner ( root ) ) . toBe (
2454+ `<div>foo:4--444</div><div>foo:4--555</div><div>foo:4--666</div><div>foo:5--444</div><div>foo:5--555</div><div>foo:5--666</div><div>foo:6--444</div><div>foo:6--555</div><div>foo:6--666</div>` ,
2455+ )
2456+ } )
2457+
23632458 test ( 'should call unmounted directive once when fallback is replaced by resolved async component' , async ( ) => {
23642459 const Comp = {
23652460 render ( ) {
0 commit comments