File tree 2 files changed +33
-1
lines changed
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -137,4 +137,20 @@ describe('ssr: slot', () => {
137
137
) ,
138
138
) . toBe ( `<div>foo</div>` )
139
139
} )
140
+
141
+ // #9933
142
+ test ( 'transition-group slot' , async ( ) => {
143
+ expect (
144
+ await renderToString (
145
+ createApp ( {
146
+ components : {
147
+ one : {
148
+ template : `<TransitionGroup tag="div"><slot/></TransitionGroup>` ,
149
+ } ,
150
+ } ,
151
+ template : `<one><p v-for="i in 2">{{i}}</p></one>` ,
152
+ } ) ,
153
+ ) ,
154
+ ) . toBe ( `<div><p>1</p><p>2</p></div>` )
155
+ } )
140
156
} )
Original file line number Diff line number Diff line change @@ -82,7 +82,23 @@ export function ssrRenderSlotInner(
82
82
fallbackRenderFn ( )
83
83
}
84
84
} else {
85
- for ( let i = 0 ; i < slotBuffer . length ; i ++ ) {
85
+ // #9933
86
+ // Although we handle Transition/TransitionGroup in the transform stage
87
+ // without rendering it as a fragment, the content passed into the slot
88
+ // may still be a fragment.
89
+ // Therefore, here we need to avoid rendering it as a fragment again.
90
+ let start = 0
91
+ let end = slotBuffer . length
92
+ if (
93
+ transition &&
94
+ slotBuffer [ 0 ] === '<!--[-->' &&
95
+ slotBuffer [ end - 1 ] === '<!--]-->'
96
+ ) {
97
+ start ++
98
+ end --
99
+ }
100
+
101
+ for ( let i = start ; i < end ; i ++ ) {
86
102
push ( slotBuffer [ i ] )
87
103
}
88
104
}
You can’t perform that action at this time.
0 commit comments