Skip to content

Commit bac645b

Browse files
committed
chore: update codegen
1 parent b6ec6e9 commit bac645b

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ describe('transition-group', () => {
1111
"const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
1212
1313
return function ssrRender(_ctx, _push, _parent, _attrs) {
14-
if (_attrs && _attrs.tag) {
15-
_push(\`<\${_attrs.tag}>\`)
14+
const _tag = _attrs && _attrs.tag
15+
if (_tag) {
16+
_push(\`<\${_tag}>\`)
1617
}
1718
_push(\`<!--[-->\`)
1819
_ssrRenderList(_ctx.list, (i) => {
1920
_push(\`<div></div>\`)
2021
})
2122
_push(\`<!--]-->\`)
22-
if (_attrs && _attrs.tag) {
23-
_push(\`</\${_attrs.tag}>\`)
23+
if (_tag) {
24+
_push(\`</\${_tag}>\`)
2425
}
2526
}"
2627
`)
@@ -120,8 +121,9 @@ describe('transition-group', () => {
120121
"const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
121122
122123
return function ssrRender(_ctx, _push, _parent, _attrs) {
123-
if (_attrs && _attrs.tag) {
124-
_push(\`<\${_attrs.tag}>\`)
124+
const _tag = _attrs && _attrs.tag
125+
if (_tag) {
126+
_push(\`<\${_tag}>\`)
125127
}
126128
_push(\`<!--[-->\`)
127129
_ssrRenderList(10, (i) => {
@@ -134,8 +136,8 @@ describe('transition-group', () => {
134136
_push(\`<div>ok</div>\`)
135137
}
136138
_push(\`<!--]-->\`)
137-
if (_attrs && _attrs.tag) {
138-
_push(\`</\${_attrs.tag}>\`)
139+
if (_tag) {
140+
_push(\`</\${_tag}>\`)
139141
}
140142
}"
141143
`)

packages/compiler-ssr/src/ssrCodegenTransform.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
type CompilerError,
55
type CompilerOptions,
66
ElementTypes,
7+
type ExpressionNode,
78
type IfStatement,
89
type JSChildNode,
910
NodeTypes,
@@ -84,7 +85,7 @@ export interface SSRTransformContext {
8485
onError: (error: CompilerError) => void
8586
helper<T extends symbol>(name: T): T
8687
pushStringPart(part: TemplateLiteral['elements'][0]): void
87-
pushStatement(statement: IfStatement | CallExpression): void
88+
pushStatement(statement: IfStatement | CallExpression | ExpressionNode): void
8889
}
8990

9091
function createSSRTransformContext(

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,13 @@ export function ssrProcessTransitionGroup(
125125
p.exp.content === '_attrs',
126126
)
127127
if (hasFallthroughAttrs) {
128+
context.pushStatement(
129+
createSimpleExpression('const _tag = _attrs && _attrs.tag'),
130+
)
128131
context.pushStatement(
129132
createIfStatement(
130-
createSimpleExpression('_attrs && _attrs.tag'),
131-
createBlockStatement([
132-
createSimpleExpression('_push(`<${_attrs.tag}>`)'),
133-
]),
133+
createSimpleExpression('_tag'),
134+
createBlockStatement([createSimpleExpression('_push(`<${_tag}>`)')]),
134135
),
135136
)
136137
}
@@ -140,10 +141,8 @@ export function ssrProcessTransitionGroup(
140141
if (hasFallthroughAttrs) {
141142
context.pushStatement(
142143
createIfStatement(
143-
createSimpleExpression('_attrs && _attrs.tag'),
144-
createBlockStatement([
145-
createSimpleExpression('_push(`</${_attrs.tag}>`)'),
146-
]),
144+
createSimpleExpression('_tag'),
145+
createBlockStatement([createSimpleExpression('_push(`</${_tag}>`)')]),
147146
),
148147
)
149148
}

0 commit comments

Comments
 (0)