})
// #11514
- test('with static tag + comment', () => {
+ test('with static tag + v-if comment', () => {
expect(
compile(
`<transition-group tag="ul"><div v-for="i in list"/><div v-if="false"></div></transition-group>`,
`)
})
+ // #11958
+ test('with static tag + comment', () => {
+ expect(
+ compile(
+ `<transition-group tag="ul"><div v-for="i in list"/><!--test--></transition-group>`,
+ ).code,
+ ).toMatchInlineSnapshot(`
+ "const { ssrRenderAttrs: _ssrRenderAttrs, ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
+
+ return function ssrRender(_ctx, _push, _parent, _attrs) {
+ _push(\`<ul\${_ssrRenderAttrs(_attrs)}>\`)
+ _ssrRenderList(_ctx.list, (i) => {
+ _push(\`<div></div>\`)
+ })
+ _push(\`</ul>\`)
+ }"
+ `)
+ })
+
test('with dynamic tag', () => {
expect(
compile(
context: SSRTransformContext,
asFragment = false,
disableNestedFragments = false,
- disableCommentAsIfAlternate = false,
+ disableComment = false,
): void {
if (asFragment) {
context.pushStringPart(`<!--[-->`)
case NodeTypes.COMMENT:
// no need to escape comment here because the AST can only
// contain valid comments.
- context.pushStringPart(`<!--${child.content}-->`)
+ if (!disableComment) {
+ context.pushStringPart(`<!--${child.content}-->`)
+ }
break
case NodeTypes.INTERPOLATION:
context.pushStringPart(
)
break
case NodeTypes.IF:
- ssrProcessIf(
- child,
- context,
- disableNestedFragments,
- disableCommentAsIfAlternate,
- )
+ ssrProcessIf(child, context, disableNestedFragments, disableComment)
break
case NodeTypes.FOR:
ssrProcessFor(child, context, disableNestedFragments)
node: IfNode,
context: SSRTransformContext,
disableNestedFragments = false,
- disableCommentAsIfAlternate = false,
+ disableComment = false,
): void {
const [rootBranch] = node.branches
const ifStatement = createIfStatement(
}
}
- if (!currentIf.alternate && !disableCommentAsIfAlternate) {
+ if (!currentIf.alternate && !disableComment) {
currentIf.alternate = createBlockStatement([
createCallExpression(`_push`, ['`<!---->`']),
])