From: daiwei Date: Sat, 8 Feb 2025 08:06:34 +0000 (+0800) Subject: chore: update codegen X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12829%2Fhead;p=thirdparty%2Fvuejs%2Fcore.git chore: update codegen test: add test --- diff --git a/packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts b/packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts index cd98d8c7e2..4ca320b78b 100644 --- a/packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts +++ b/packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts @@ -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}>\`) } diff --git a/packages/compiler-ssr/src/transforms/ssrTransformTransitionGroup.ts b/packages/compiler-ssr/src/transforms/ssrTransformTransitionGroup.ts index e1669a5940..831dffb839 100644 --- a/packages/compiler-ssr/src/transforms/ssrTransformTransitionGroup.ts +++ b/packages/compiler-ssr/src/transforms/ssrTransformTransitionGroup.ts @@ -115,7 +115,7 @@ export function ssrProcessTransitionGroup( context.pushStringPart(``) } } 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( diff --git a/packages/server-renderer/__tests__/ssrAttrFallthrough.spec.ts b/packages/server-renderer/__tests__/ssrAttrFallthrough.spec.ts index e8cfa75e77..66f6688b7f 100644 --- a/packages/server-renderer/__tests__/ssrAttrFallthrough.spec.ts +++ b/packages/server-renderer/__tests__/ssrAttrFallthrough.spec.ts @@ -75,4 +75,20 @@ describe('ssr: attr fallthrough', () => { `
`, ) }) + + // #12827 + test('with transition-group tag name', async () => { + expect( + await renderToString( + createApp({ + components: { + one: { + template: ``, + }, + }, + template: `

{{i}}

`, + }), + ), + ).toBe(`

1

2

`) + }) })