File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -137,4 +137,20 @@ describe('ssr: slot', () => {
137137 ) ,
138138 ) . toBe ( `<div>foo</div>` )
139139 } )
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+ } )
140156} )
Original file line number Diff line number Diff line change @@ -82,7 +82,23 @@ export function ssrRenderSlotInner(
8282 fallbackRenderFn ( )
8383 }
8484 } 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 ++ ) {
86102 push ( slotBuffer [ i ] )
87103 }
88104 }
You can’t perform that action at this time.
0 commit comments