File tree Expand file tree Collapse file tree 4 files changed +31
-11
lines changed Expand file tree Collapse file tree 4 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -1681,7 +1681,7 @@ describe('SSR hydration', () => {
1681
1681
test ( 'transition appear work with empty content' , async ( ) => {
1682
1682
const show = ref ( true )
1683
1683
const { vnode, container } = mountWithHydration (
1684
- `<template></template>` ,
1684
+ `<template><!---->< /template>` ,
1685
1685
function ( this : any ) {
1686
1686
return h (
1687
1687
Transition ,
@@ -1696,7 +1696,7 @@ describe('SSR hydration', () => {
1696
1696
} ,
1697
1697
)
1698
1698
1699
- // expect empty slot render as a comment node
1699
+ // empty slot render as a comment node
1700
1700
expect ( container . firstChild ! . nodeType ) . toBe ( Node . COMMENT_NODE )
1701
1701
expect ( vnode . el ) . toBe ( container . firstChild )
1702
1702
expect ( `mismatch` ) . not . toHaveBeenWarned ( )
Original file line number Diff line number Diff line change @@ -202,9 +202,7 @@ export function createHydrationFunctions(
202
202
// wrapped <transition appear>
203
203
// replace <template> node with inner child
204
204
replaceNode (
205
- // #13394, the server may render an empty <template>, a comment node
206
- // needs to be created to be consistent with the client's behavior
207
- ( vnode . el = node . content . firstChild || createComment ( '' ) ) ,
205
+ ( vnode . el = node . content . firstChild ! ) ,
208
206
node ,
209
207
parentComponent ,
210
208
)
@@ -399,11 +397,9 @@ export function createHydrationFunctions(
399
397
parentComponent . vnode . props &&
400
398
parentComponent . vnode . props . appear
401
399
402
- let content =
403
- ( el . content . firstChild as Element & { $cls ?: string } ) ||
404
- createComment ( '' )
400
+ let content = el . content . firstChild as Element & { $cls ?: string }
405
401
406
- if ( needCallTransitionHooks && content instanceof Element ) {
402
+ if ( needCallTransitionHooks ) {
407
403
const cls = content . getAttribute ( 'class' )
408
404
if ( cls ) content . $cls = cls
409
405
transition ! . beforeEnter ( content )
Original file line number Diff line number Diff line change @@ -124,6 +124,22 @@ describe('ssr: slot', () => {
124
124
) ,
125
125
) . toBe ( `<!---->` )
126
126
127
+ expect (
128
+ await renderToString (
129
+ createApp ( {
130
+ template : `<transition><slot/></transition>` ,
131
+ } ) ,
132
+ ) ,
133
+ ) . toBe ( `<!---->` )
134
+
135
+ expect (
136
+ await renderToString (
137
+ createApp ( {
138
+ template : `<transition><slot v-if="false"/></transition>` ,
139
+ } ) ,
140
+ ) ,
141
+ ) . toBe ( `<!---->` )
142
+
127
143
expect (
128
144
await renderToString (
129
145
createApp ( {
Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ export function ssrRenderSlotInner(
74
74
)
75
75
} else if ( fallbackRenderFn ) {
76
76
fallbackRenderFn ( )
77
+ } else if ( transition ) {
78
+ push ( `<!---->` )
77
79
}
78
80
} else {
79
81
// ssr slot.
@@ -110,13 +112,19 @@ export function ssrRenderSlotInner(
110
112
end --
111
113
}
112
114
113
- for ( let i = start ; i < end ; i ++ ) {
114
- push ( slotBuffer [ i ] )
115
+ if ( start < end ) {
116
+ for ( let i = start ; i < end ; i ++ ) {
117
+ push ( slotBuffer [ i ] )
118
+ }
119
+ } else {
120
+ push ( `<!---->` )
115
121
}
116
122
}
117
123
}
118
124
} else if ( fallbackRenderFn ) {
119
125
fallbackRenderFn ( )
126
+ } else if ( transition ) {
127
+ push ( `<!---->` )
120
128
}
121
129
}
122
130
You can’t perform that action at this time.
0 commit comments