@@ -275,14 +275,6 @@ describe('ssr: components', () => {
275
275
}"
276
276
` )
277
277
278
- expect ( compile ( `<transition-group><div/></transition-group>` ) . code )
279
- . toMatchInlineSnapshot ( `
280
- "
281
- return function ssrRender(_ctx, _push, _parent, _attrs) {
282
- _push(\`<!--[--><div></div><!--]-->\`)
283
- }"
284
- ` )
285
-
286
278
expect ( compile ( `<keep-alive><foo/></keep-alive>` ) . code )
287
279
. toMatchInlineSnapshot ( `
288
280
"const { resolveComponent: _resolveComponent } = require(\\"vue\\")
@@ -295,5 +287,93 @@ describe('ssr: components', () => {
295
287
}"
296
288
` )
297
289
} )
290
+
291
+ // transition-group should flatten and concat its children fragments into
292
+ // a single one
293
+ describe ( 'transition-group' , ( ) => {
294
+ test ( 'basic' , ( ) => {
295
+ expect (
296
+ compile (
297
+ `<transition-group><div v-for="i in list"/></transition-group>`
298
+ ) . code
299
+ ) . toMatchInlineSnapshot ( `
300
+ "const { ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
301
+
302
+ return function ssrRender(_ctx, _push, _parent, _attrs) {
303
+ _push(\`<!--[-->\`)
304
+ _ssrRenderList(_ctx.list, (i) => {
305
+ _push(\`<div></div>\`)
306
+ })
307
+ _push(\`<!--]-->\`)
308
+ }"
309
+ ` )
310
+ } )
311
+
312
+ test ( 'with static tag' , ( ) => {
313
+ expect (
314
+ compile (
315
+ `<transition-group tag="ul"><div v-for="i in list"/></transition-group>`
316
+ ) . code
317
+ ) . toMatchInlineSnapshot ( `
318
+ "const { ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
319
+
320
+ return function ssrRender(_ctx, _push, _parent, _attrs) {
321
+ _push(\`<ul>\`)
322
+ _ssrRenderList(_ctx.list, (i) => {
323
+ _push(\`<div></div>\`)
324
+ })
325
+ _push(\`</ul>\`)
326
+ }"
327
+ ` )
328
+ } )
329
+
330
+ test ( 'with dynamic tag' , ( ) => {
331
+ expect (
332
+ compile (
333
+ `<transition-group :tag="someTag"><div v-for="i in list"/></transition-group>`
334
+ ) . code
335
+ ) . toMatchInlineSnapshot ( `
336
+ "const { ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
337
+
338
+ return function ssrRender(_ctx, _push, _parent, _attrs) {
339
+ _push(\`<\${_ctx.someTag}>\`)
340
+ _ssrRenderList(_ctx.list, (i) => {
341
+ _push(\`<div></div>\`)
342
+ })
343
+ _push(\`</\${_ctx.someTag}>\`)
344
+ }"
345
+ ` )
346
+ } )
347
+
348
+ test ( 'with multi fragments children' , ( ) => {
349
+ expect (
350
+ compile (
351
+ `<transition-group>
352
+ <div v-for="i in 10"/>
353
+ <div v-for="i in 10"/>
354
+ <template v-if="ok"><div>ok</div></template>
355
+ </transition-group>`
356
+ ) . code
357
+ ) . toMatchInlineSnapshot ( `
358
+ "const { ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
359
+
360
+ return function ssrRender(_ctx, _push, _parent, _attrs) {
361
+ _push(\`<!--[-->\`)
362
+ _ssrRenderList(10, (i) => {
363
+ _push(\`<div></div>\`)
364
+ })
365
+ _ssrRenderList(10, (i) => {
366
+ _push(\`<div></div>\`)
367
+ })
368
+ if (_ctx.ok) {
369
+ _push(\`<div>ok</div>\`)
370
+ } else {
371
+ _push(\`<!---->\`)
372
+ }
373
+ _push(\`<!--]-->\`)
374
+ }"
375
+ ` )
376
+ } )
377
+ } )
298
378
} )
299
379
} )
0 commit comments