File tree Expand file tree Collapse file tree 4 files changed +16
-9
lines changed Expand file tree Collapse file tree 4 files changed +16
-9
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,10 @@ 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
+ const content = ( el as HTMLTemplateElement ) . content
401
+ . firstChild as Element & { $cls ?: string }
405
402
406
- if ( needCallTransitionHooks && content instanceof Element ) {
403
+ if ( needCallTransitionHooks ) {
407
404
const cls = content . getAttribute ( 'class' )
408
405
if ( cls ) content . $cls = cls
409
406
transition ! . beforeEnter ( content )
Original file line number Diff line number Diff line change @@ -124,6 +124,14 @@ 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
+
127
135
expect (
128
136
await renderToString (
129
137
createApp ( {
Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ export function ssrRenderSlotInner(
117
117
}
118
118
} else if ( fallbackRenderFn ) {
119
119
fallbackRenderFn ( )
120
+ } else if ( transition ) {
121
+ push ( `<!---->` )
120
122
}
121
123
}
122
124
You can’t perform that action at this time.
0 commit comments