File tree 2 files changed +65
-1
lines changed
runtime-core/src/components
2 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -551,6 +551,8 @@ function createSuspenseBoundary(
551
551
if ( delayEnter ) {
552
552
activeBranch ! . transition ! . afterLeave = mountFallback
553
553
}
554
+ suspense . isInFallback = true
555
+
554
556
// unmount current active branch
555
557
unmount (
556
558
activeBranch ! ,
@@ -559,7 +561,6 @@ function createSuspenseBoundary(
559
561
true // shouldRemove
560
562
)
561
563
562
- suspense . isInFallback = true
563
564
if ( ! delayEnter ) {
564
565
mountFallback ( )
565
566
}
Original file line number Diff line number Diff line change @@ -1325,6 +1325,69 @@ describe('e2e: Transition', () => {
1325
1325
} ,
1326
1326
E2E_TIMEOUT
1327
1327
)
1328
+
1329
+ // #3963
1330
+ test (
1331
+ 'Suspense fallback should work with transition' ,
1332
+ async ( ) => {
1333
+ await page ( ) . evaluate ( ( ) => {
1334
+ const { createApp, shallowRef, h } = ( window as any ) . Vue
1335
+
1336
+ const One = {
1337
+ template : `<div>{{ msg }}</div>` ,
1338
+ setup ( ) {
1339
+ return new Promise ( _resolve => {
1340
+ // @ts -ignore
1341
+ window . resolve = ( ) =>
1342
+ _resolve ( {
1343
+ msg : 'success'
1344
+ } )
1345
+ } )
1346
+ }
1347
+ }
1348
+
1349
+ createApp ( {
1350
+ template : `
1351
+ <div id="container">
1352
+ <transition mode="out-in">
1353
+ <Suspense :timeout="0">
1354
+ <template #default>
1355
+ <component :is="view" />
1356
+ </template>
1357
+ <template #fallback>
1358
+ <div>Loading...</div>
1359
+ </template>
1360
+ </Suspense>
1361
+ </transition>
1362
+ </div>
1363
+ <button id="toggleBtn" @click="click">button</button>
1364
+ ` ,
1365
+ setup : ( ) => {
1366
+ const view = shallowRef ( null )
1367
+ const click = ( ) => {
1368
+ view . value = view . value ? null : h ( One )
1369
+ }
1370
+ return { view, click }
1371
+ }
1372
+ } ) . mount ( '#app' )
1373
+ } )
1374
+
1375
+ expect ( await html ( '#container' ) ) . toBe ( '<!---->' )
1376
+
1377
+ await click ( '#toggleBtn' )
1378
+ await nextFrame ( )
1379
+ expect ( await html ( '#container' ) ) . toBe ( '<div class="">Loading...</div>' )
1380
+
1381
+ await page ( ) . evaluate ( ( ) => {
1382
+ // @ts -ignore
1383
+ window . resolve ( )
1384
+ } )
1385
+
1386
+ await transitionFinish ( duration * 2 )
1387
+ expect ( await html ( '#container' ) ) . toBe ( '<div class="">success</div>' )
1388
+ } ,
1389
+ E2E_TIMEOUT
1390
+ )
1328
1391
} )
1329
1392
1330
1393
describe ( 'transition with v-show' , ( ) => {
You can’t perform that action at this time.
0 commit comments