@@ -17,6 +17,8 @@ import {
17
17
onUnmounted ,
18
18
ref ,
19
19
render ,
20
+ renderList ,
21
+ renderSlot ,
20
22
resolveDynamicComponent ,
21
23
serializeInner ,
22
24
shallowRef ,
@@ -2161,6 +2163,82 @@ describe('Suspense', () => {
2161
2163
await Promise . all ( deps )
2162
2164
} )
2163
2165
2166
+ // #13453
2167
+ test ( 'add new async deps during patching' , async ( ) => {
2168
+ const getComponent = ( type : string ) => {
2169
+ if ( type === 'A' ) {
2170
+ return defineAsyncComponent ( {
2171
+ name : 'A' ,
2172
+ setup ( ) {
2173
+ return ( ) => h ( 'div' , 'A' )
2174
+ } ,
2175
+ } )
2176
+ }
2177
+ return defineAsyncComponent ( {
2178
+ name : 'A' ,
2179
+ setup ( ) {
2180
+ return ( ) => h ( 'div' , 'B' )
2181
+ } ,
2182
+ } )
2183
+ }
2184
+
2185
+ const types = ref ( [ 'A' ] )
2186
+ const add = async ( ) => {
2187
+ types . value . push ( 'B' )
2188
+ }
2189
+
2190
+ const update = async ( ) => {
2191
+ // mount Suspense B
2192
+ // [Suspense A] -> [Suspense A(pending), Suspense B(pending)]
2193
+ await add ( )
2194
+ // patch Suspense B (still pending)
2195
+ // [Suspense A(pending), Suspense B(pending)] -> [Suspense B(pending)]
2196
+ types . value . shift ( )
2197
+ }
2198
+
2199
+ const Comp = {
2200
+ render ( this : any ) {
2201
+ return h ( Fragment , null , [
2202
+ renderList ( types . value , type => {
2203
+ return h (
2204
+ Suspense ,
2205
+ { key : type } ,
2206
+ {
2207
+ default : ( ) => [
2208
+ renderSlot ( this . $slots , 'default' , { type : type } ) ,
2209
+ ] ,
2210
+ } ,
2211
+ )
2212
+ } ) ,
2213
+ ] )
2214
+ } ,
2215
+ }
2216
+
2217
+ const App = {
2218
+ setup ( ) {
2219
+ return ( ) =>
2220
+ h ( Comp , null , {
2221
+ default : ( params : any ) => [ h ( getComponent ( params . type ) ) ] ,
2222
+ } )
2223
+ } ,
2224
+ }
2225
+
2226
+ const root = nodeOps . createElement ( 'div' )
2227
+ render ( h ( App ) , root )
2228
+ expect ( serializeInner ( root ) ) . toBe ( `<!---->` )
2229
+
2230
+ await Promise . all ( deps )
2231
+ expect ( serializeInner ( root ) ) . toBe ( `<div>A</div>` )
2232
+
2233
+ update ( )
2234
+ await nextTick ( )
2235
+ // wait for both A and B to resolve
2236
+ await Promise . all ( deps )
2237
+ // wait for new B to resolve
2238
+ await Promise . all ( deps )
2239
+ expect ( serializeInner ( root ) ) . toBe ( `<div>B</div>` )
2240
+ } )
2241
+
2164
2242
describe ( 'warnings' , ( ) => {
2165
2243
// base function to check if a combination of slots warns or not
2166
2244
function baseCheckWarn (
0 commit comments