]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-ssr): don't render v-if comments in TransitionGroup + static tag (#11515)
authoredison <daiwei521@126.com>
Tue, 6 Aug 2024 10:25:13 +0000 (18:25 +0800)
committerGitHub <noreply@github.com>
Tue, 6 Aug 2024 10:25:13 +0000 (18:25 +0800)
close #11514

packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts
packages/compiler-ssr/src/transforms/ssrTransformTransitionGroup.ts

index 905e6a4895d6d2cba020c7fb0009acf3d596f6b8..431ebaa77ee25ac63ddf6437d3615c40313c012c 100644 (file)
@@ -38,6 +38,28 @@ describe('transition-group', () => {
     `)
   })
 
+  // #11514
+  test('with static tag + comment', () => {
+    expect(
+      compile(
+        `<transition-group tag="ul"><div v-for="i in list"/><div v-if="false"></div></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>\`)
+        })
+        if (false) {
+          _push(\`<div></div>\`)
+        }
+        _push(\`</ul>\`)
+      }"
+    `)
+  })
+
   test('with dynamic tag', () => {
     expect(
       compile(
index a2e284ae84158fa621ee52eb0439b34a04ad3ce7..1d99a6910940d34f9e6a8e1eb534d90f2a77de14 100644 (file)
@@ -108,7 +108,7 @@ export function ssrProcessTransitionGroup(
         context.pushStringPart(` ${scopeId}`)
       }
       context.pushStringPart(`>`)
-      processChildren(node, context, false, true)
+      processChildren(node, context, false, true, true)
       context.pushStringPart(`</${tag.value!.content}>`)
     }
   } else {