File tree 2 files changed +50
-1
lines changed
2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 1
1
import {
2
2
Fragment ,
3
+ Suspense ,
3
4
createBlock ,
4
5
createCommentVNode ,
5
6
createVNode ,
@@ -47,6 +48,49 @@ describe('scopeId runtime support', () => {
47
48
)
48
49
} )
49
50
51
+ // #5148
52
+ test ( 'should attach scopeId to suspense content' , async ( ) => {
53
+ const deps : Promise < any > [ ] = [ ]
54
+ const Child = {
55
+ async setup ( ) {
56
+ const p = new Promise ( r => setTimeout ( r , 1 ) )
57
+ deps . push ( p . then ( ( ) => Promise . resolve ( ) ) )
58
+
59
+ await p
60
+ return ( ) => h ( 'div' , 'async' )
61
+ } ,
62
+ }
63
+
64
+ const Wrapper = {
65
+ setup ( _ : any , { slots } : any ) {
66
+ return ( ) => slots . default ( { Component : h ( Child ) } )
67
+ } ,
68
+ }
69
+
70
+ const App = {
71
+ __scopeId : 'parent' ,
72
+ setup ( ) {
73
+ return ( ) =>
74
+ h ( Wrapper , null , {
75
+ default : withCtx ( ( { Component } : any ) =>
76
+ h ( Suspense , null , {
77
+ default : h ( Component ) ,
78
+ fallback : h ( 'div' , 'fallback' ) ,
79
+ } ) ,
80
+ ) ,
81
+ } )
82
+ } ,
83
+ }
84
+
85
+ const root = nodeOps . createElement ( 'div' )
86
+ render ( h ( App ) , root )
87
+ expect ( serializeInner ( root ) ) . toBe ( `<div parent>fallback</div>` )
88
+
89
+ await Promise . all ( deps )
90
+ await nextTick ( )
91
+ expect ( serializeInner ( root ) ) . toBe ( `<div parent>async</div>` )
92
+ } )
93
+
50
94
// :slotted basic
51
95
test ( 'should work on slots' , ( ) => {
52
96
const Child = {
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ import { setRef } from './rendererTemplateRef'
62
62
import {
63
63
type SuspenseBoundary ,
64
64
type SuspenseImpl ,
65
+ isSuspense ,
65
66
queueEffectWithSuspense ,
66
67
} from './components/Suspense'
67
68
import {
@@ -749,7 +750,11 @@ function baseCreateRenderer(
749
750
subTree =
750
751
filterSingleRoot ( subTree . children as VNodeArrayChildren ) || subTree
751
752
}
752
- if ( vnode === subTree ) {
753
+ if (
754
+ vnode === subTree ||
755
+ ( isSuspense ( subTree . type ) &&
756
+ ( subTree . ssContent === vnode || subTree . ssFallback === vnode ) )
757
+ ) {
753
758
const parentVNode = parentComponent . vnode
754
759
setScopeId (
755
760
el ,
You can’t perform that action at this time.
0 commit comments