]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: update codegen edison/fix/12827 12829/head
authordaiwei <daiwei521@126.com>
Sat, 8 Feb 2025 08:06:34 +0000 (16:06 +0800)
committerdaiwei <daiwei521@126.com>
Sat, 8 Feb 2025 08:38:34 +0000 (16:38 +0800)
test: add test

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

index cd98d8c7e2af0a727fa8031e668a79fca83b60a7..4ca320b78b59830f1bd33e6d1f4f98369a7af75e 100644 (file)
@@ -11,7 +11,7 @@ describe('transition-group', () => {
       "const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
       return function ssrRender(_ctx, _push, _parent, _attrs) {
-        const _tag = _attrs && _attrs.tag
+        const _tag = (_attrs && typeof _attrs.tag === 'string') ? _attrs.tag : ''
         if (_tag) {
           _push(\`<\${_tag}>\`)
         }
@@ -121,7 +121,7 @@ describe('transition-group', () => {
       "const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
       return function ssrRender(_ctx, _push, _parent, _attrs) {
-        const _tag = _attrs && _attrs.tag
+        const _tag = (_attrs && typeof _attrs.tag === 'string') ? _attrs.tag : ''
         if (_tag) {
           _push(\`<\${_tag}>\`)
         }
index e1669a594031db4a271670291706f1014fc58c40..831dffb8393e4497eac0cfcdd8b9f01c10be554d 100644 (file)
@@ -115,7 +115,7 @@ export function ssrProcessTransitionGroup(
       context.pushStringPart(`</${tag.value!.content}>`)
     }
   } else {
-    // #12827 _attrs fallthrough may contain tag property
+    // _attrs may contain tag property
     const hasFallthroughAttrs = node.props.some(
       p =>
         p.type === NodeTypes.DIRECTIVE &&
@@ -126,7 +126,9 @@ export function ssrProcessTransitionGroup(
     )
     if (hasFallthroughAttrs) {
       context.pushStatement(
-        createSimpleExpression('const _tag = _attrs && _attrs.tag'),
+        createSimpleExpression(
+          `const _tag = (_attrs && typeof _attrs.tag === 'string') ? _attrs.tag : ''`,
+        ),
       )
       context.pushStatement(
         createIfStatement(
index e8cfa75e77c58e03435bf9452a4110bbb42199fd..66f6688b7f3aad68487eacf1abd516d84c73560b 100644 (file)
@@ -75,4 +75,20 @@ describe('ssr: attr fallthrough', () => {
       `<div id="foo" class="bar baz"></div>`,
     )
   })
+
+  // #12827
+  test('with transition-group tag name', async () => {
+    expect(
+      await renderToString(
+        createApp({
+          components: {
+            one: {
+              template: `<TransitionGroup><slot/></TransitionGroup>`,
+            },
+          },
+          template: `<one tag="div"><p v-for="i in 2">{{i}}</p></one>`,
+        }),
+      ),
+    ).toBe(`<div><!--[--><p>1</p><p>2</p><!--]--></div>`)
+  })
 })