Skip to content

Commit 92bf78e

Browse files
committed
chore: update codegen
test: add test
1 parent bac645b commit 92bf78e

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('transition-group', () => {
1111
"const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
1212
1313
return function ssrRender(_ctx, _push, _parent, _attrs) {
14-
const _tag = _attrs && _attrs.tag
14+
const _tag = (_attrs && typeof _attrs.tag === 'string') ? _attrs.tag : ''
1515
if (_tag) {
1616
_push(\`<\${_tag}>\`)
1717
}
@@ -121,7 +121,7 @@ describe('transition-group', () => {
121121
"const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
122122
123123
return function ssrRender(_ctx, _push, _parent, _attrs) {
124-
const _tag = _attrs && _attrs.tag
124+
const _tag = (_attrs && typeof _attrs.tag === 'string') ? _attrs.tag : ''
125125
if (_tag) {
126126
_push(\`<\${_tag}>\`)
127127
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function ssrProcessTransitionGroup(
115115
context.pushStringPart(`</${tag.value!.content}>`)
116116
}
117117
} else {
118-
// #12827 _attrs fallthrough may contain tag property
118+
// _attrs may contain tag property
119119
const hasFallthroughAttrs = node.props.some(
120120
p =>
121121
p.type === NodeTypes.DIRECTIVE &&
@@ -126,7 +126,9 @@ export function ssrProcessTransitionGroup(
126126
)
127127
if (hasFallthroughAttrs) {
128128
context.pushStatement(
129-
createSimpleExpression('const _tag = _attrs && _attrs.tag'),
129+
createSimpleExpression(
130+
`const _tag = (_attrs && typeof _attrs.tag === 'string') ? _attrs.tag : ''`,
131+
),
130132
)
131133
context.pushStatement(
132134
createIfStatement(

packages/server-renderer/__tests__/ssrAttrFallthrough.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,20 @@ describe('ssr: attr fallthrough', () => {
7575
`<div id="foo" class="bar baz"></div>`,
7676
)
7777
})
78+
79+
// #12827
80+
test('with transition-group tag name', async () => {
81+
expect(
82+
await renderToString(
83+
createApp({
84+
components: {
85+
one: {
86+
template: `<TransitionGroup><slot/></TransitionGroup>`,
87+
},
88+
},
89+
template: `<one tag="div"><p v-for="i in 2">{{i}}</p></one>`,
90+
}),
91+
),
92+
).toBe(`<div><!--[--><p>1</p><p>2</p><!--]--></div>`)
93+
})
7894
})

0 commit comments

Comments
 (0)