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