File tree 2 files changed +54
-3
lines changed
2 files changed +54
-3
lines changed Original file line number Diff line number Diff line change @@ -688,6 +688,54 @@ describe('SSR hydration', () => {
688
688
expect ( container . innerHTML ) . toBe ( `<span>1</span>` )
689
689
} )
690
690
691
+ // #6638
692
+ test ( 'Suspense + async component' , async ( ) => {
693
+ let isSuspenseResolved = false
694
+ let isSuspenseResolvedInChild : any
695
+ const AsyncChild = defineAsyncComponent ( ( ) =>
696
+ Promise . resolve (
697
+ defineComponent ( {
698
+ setup ( ) {
699
+ isSuspenseResolvedInChild = isSuspenseResolved
700
+ const count = ref ( 0 )
701
+ return ( ) =>
702
+ h (
703
+ 'span' ,
704
+ {
705
+ onClick : ( ) => {
706
+ count . value ++
707
+ } ,
708
+ } ,
709
+ count . value ,
710
+ )
711
+ } ,
712
+ } ) ,
713
+ ) ,
714
+ )
715
+ const { vnode, container } = mountWithHydration ( '<span>0</span>' , ( ) =>
716
+ h (
717
+ Suspense ,
718
+ {
719
+ onResolve ( ) {
720
+ isSuspenseResolved = true
721
+ } ,
722
+ } ,
723
+ ( ) => h ( AsyncChild ) ,
724
+ ) ,
725
+ )
726
+ expect ( vnode . el ) . toBe ( container . firstChild )
727
+ // wait for hydration to finish
728
+ await new Promise ( r => setTimeout ( r ) )
729
+
730
+ expect ( isSuspenseResolvedInChild ) . toBe ( false )
731
+ expect ( isSuspenseResolved ) . toBe ( true )
732
+
733
+ // assert interaction
734
+ triggerEvent ( 'click' , container . querySelector ( 'span' ) ! )
735
+ await nextTick ( )
736
+ expect ( container . innerHTML ) . toBe ( `<span>1</span>` )
737
+ } )
738
+
691
739
test ( 'Suspense (full integration)' , async ( ) => {
692
740
const mountedCalls : number [ ] = [ ]
693
741
const asyncDeps : Promise < any > [ ] = [ ]
Original file line number Diff line number Diff line change @@ -1276,7 +1276,7 @@ function baseCreateRenderer(
1276
1276
const componentUpdateFn = ( ) => {
1277
1277
if ( ! instance . isMounted ) {
1278
1278
let vnodeHook : VNodeHook | null | undefined
1279
- const { el, props } = initialVNode
1279
+ const { el, props, type } = initialVNode
1280
1280
const { bm, m, parent } = instance
1281
1281
const isAsyncWrapperVNode = isAsyncWrapper ( initialVNode )
1282
1282
@@ -1325,8 +1325,11 @@ function baseCreateRenderer(
1325
1325
}
1326
1326
}
1327
1327
1328
- if ( isAsyncWrapperVNode ) {
1329
- ; ( initialVNode . type as ComponentOptions ) . __asyncLoader ! ( ) . then (
1328
+ if (
1329
+ isAsyncWrapperVNode &&
1330
+ ! ( type as ComponentOptions ) . __asyncResolved
1331
+ ) {
1332
+ ; ( type as ComponentOptions ) . __asyncLoader ! ( ) . then (
1330
1333
// note: we are moving the render call into an async callback,
1331
1334
// which means it won't track dependencies - but it's ok because
1332
1335
// a server-rendered async wrapper is already in resolved state
You can’t perform that action at this time.
0 commit comments