@@ -179,4 +179,94 @@ describe('ssr: scopedId runtime behavior', () => {
179
179
const result = await renderToString ( createApp ( Comp ) ) // output: `<div></div>`
180
180
expect ( result ) . toBe ( `<div parent></div>` )
181
181
} )
182
+
183
+ // #6093
184
+ test ( ':slotted on forwarded slots on component' , async ( ) => {
185
+ const Wrapper = {
186
+ __scopeId : 'wrapper' ,
187
+ ssrRender : ( ctx : any , push : any , parent : any , attrs : any ) => {
188
+ // <div class="wrapper"><slot/></div>
189
+ push (
190
+ `<div${ ssrRenderAttrs (
191
+ mergeProps ( { class : 'wrapper' } , attrs ) ,
192
+ ) } wrapper>`,
193
+ )
194
+ ssrRenderSlot (
195
+ ctx . $slots ,
196
+ 'default' ,
197
+ { } ,
198
+ null ,
199
+ push ,
200
+ parent ,
201
+ 'wrapper-s' ,
202
+ )
203
+ push ( `</div>` )
204
+ } ,
205
+ }
206
+
207
+ const Slotted = {
208
+ __scopeId : 'slotted' ,
209
+ ssrRender : ( ctx : any , push : any , parent : any , attrs : any ) => {
210
+ // <Wrapper><slot/></Wrapper>
211
+ push (
212
+ ssrRenderComponent (
213
+ Wrapper ,
214
+ attrs ,
215
+ {
216
+ default : withCtx (
217
+ ( _ : any , push : any , parent : any , scopeId : string ) => {
218
+ ssrRenderSlot (
219
+ ctx . $slots ,
220
+ 'default' ,
221
+ { } ,
222
+ null ,
223
+ push ,
224
+ parent ,
225
+ 'slotted-s' + scopeId ,
226
+ )
227
+ } ,
228
+ ) ,
229
+ _ : 1 ,
230
+ } as any ,
231
+ parent ,
232
+ ) ,
233
+ )
234
+ } ,
235
+ }
236
+
237
+ const Child = {
238
+ ssrRender : ( ctx : any , push : any , parent : any , attrs : any ) => {
239
+ push ( `<div${ ssrRenderAttrs ( attrs ) } ></div>` )
240
+ } ,
241
+ }
242
+
243
+ const Root = {
244
+ __scopeId : 'root' ,
245
+ // <Slotted><Child></Child></Slotted>
246
+ ssrRender : ( _ : any , push : any , parent : any , attrs : any ) => {
247
+ push (
248
+ ssrRenderComponent (
249
+ Slotted ,
250
+ attrs ,
251
+ {
252
+ default : withCtx (
253
+ ( _ : any , push : any , parent : any , scopeId : string ) => {
254
+ push ( ssrRenderComponent ( Child , null , null , parent , scopeId ) )
255
+ } ,
256
+ ) ,
257
+ _ : 1 ,
258
+ } as any ,
259
+ parent ,
260
+ ) ,
261
+ )
262
+ } ,
263
+ }
264
+
265
+ const result = await renderToString ( createApp ( Root ) )
266
+ expect ( result ) . toBe (
267
+ `<div class="wrapper" root slotted wrapper>` +
268
+ `<!--[--><!--[--><div root slotted-s wrapper-s></div><!--]--><!--]-->` +
269
+ `</div>` ,
270
+ )
271
+ } )
182
272
} )
0 commit comments