Skip to content

Commit 188b108

Browse files
committed
fix(ssr): don't render comments in TransitionGroup
fix #6715
1 parent fbd697a commit 188b108

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/compiler-ssr/src/ssrCodegenTransform.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ export function processChildren(
137137
parent: Container,
138138
context: SSRTransformContext,
139139
asFragment = false,
140-
disableNestedFragments = false
140+
disableNestedFragments = false,
141+
disableCommentAsIfAlternate = false
141142
) {
142143
if (asFragment) {
143144
context.pushStringPart(`<!--[-->`)
@@ -186,7 +187,7 @@ export function processChildren(
186187
)
187188
break
188189
case NodeTypes.IF:
189-
ssrProcessIf(child, context, disableNestedFragments)
190+
ssrProcessIf(child, context, disableNestedFragments, disableCommentAsIfAlternate)
190191
break
191192
case NodeTypes.FOR:
192193
ssrProcessFor(child, context, disableNestedFragments)

packages/compiler-ssr/src/transforms/ssrTransformTransitionGroup.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ export function ssrProcessTransitionGroup(
7878
* be patched using the same key map) so we need to account for that here
7979
* by disabling nested fragment wrappers from being generated.
8080
*/
81+
true,
82+
/**
83+
* TransitionGroup filters out comment children at runtime and thus
84+
* doesn't expect comments to be present during hydration. We need to
85+
* account for that by disabling the empty comment that is otherwise
86+
* rendered for a falsy v-if that has no v-else specified. (#6715)
87+
*/
8188
true
8289
)
8390
context.pushStringPart(`</`)
@@ -95,6 +102,6 @@ export function ssrProcessTransitionGroup(
95102
}
96103
} else {
97104
// fragment
98-
processChildren(node, context, true, true)
105+
processChildren(node, context, true, true, true)
99106
}
100107
}

packages/compiler-ssr/src/transforms/ssrVIf.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export const ssrTransformIf = createStructuralDirectiveTransform(
2525
export function ssrProcessIf(
2626
node: IfNode,
2727
context: SSRTransformContext,
28-
disableNestedFragments = false
28+
disableNestedFragments = false,
29+
disableCommentAsIfAlternate = false
2930
) {
3031
const [rootBranch] = node.branches
3132
const ifStatement = createIfStatement(
@@ -54,7 +55,7 @@ export function ssrProcessIf(
5455
}
5556
}
5657

57-
if (!currentIf.alternate) {
58+
if (!currentIf.alternate && !disableCommentAsIfAlternate) {
5859
currentIf.alternate = createBlockStatement([
5960
createCallExpression(`_push`, ['`<!---->`'])
6061
])

0 commit comments

Comments
 (0)