"const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
return function ssrRender(_ctx, _push, _parent, _attrs) {
- if (_attrs && _attrs.tag) {
- _push(\`<\${_attrs.tag}>\`)
+ const _tag = _attrs && _attrs.tag
+ if (_tag) {
+ _push(\`<\${_tag}>\`)
}
_push(\`<!--[-->\`)
_ssrRenderList(_ctx.list, (i) => {
_push(\`<div></div>\`)
})
_push(\`<!--]-->\`)
- if (_attrs && _attrs.tag) {
- _push(\`</\${_attrs.tag}>\`)
+ if (_tag) {
+ _push(\`</\${_tag}>\`)
}
}"
`)
"const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
return function ssrRender(_ctx, _push, _parent, _attrs) {
- if (_attrs && _attrs.tag) {
- _push(\`<\${_attrs.tag}>\`)
+ const _tag = _attrs && _attrs.tag
+ if (_tag) {
+ _push(\`<\${_tag}>\`)
}
_push(\`<!--[-->\`)
_ssrRenderList(10, (i) => {
_push(\`<div>ok</div>\`)
}
_push(\`<!--]-->\`)
- if (_attrs && _attrs.tag) {
- _push(\`</\${_attrs.tag}>\`)
+ if (_tag) {
+ _push(\`</\${_tag}>\`)
}
}"
`)
type CompilerError,
type CompilerOptions,
ElementTypes,
+ type ExpressionNode,
type IfStatement,
type JSChildNode,
NodeTypes,
onError: (error: CompilerError) => void
helper<T extends symbol>(name: T): T
pushStringPart(part: TemplateLiteral['elements'][0]): void
- pushStatement(statement: IfStatement | CallExpression): void
+ pushStatement(statement: IfStatement | CallExpression | ExpressionNode): void
}
function createSSRTransformContext(
p.exp.content === '_attrs',
)
if (hasFallthroughAttrs) {
+ context.pushStatement(
+ createSimpleExpression('const _tag = _attrs && _attrs.tag'),
+ )
context.pushStatement(
createIfStatement(
- createSimpleExpression('_attrs && _attrs.tag'),
- createBlockStatement([
- createSimpleExpression('_push(`<${_attrs.tag}>`)'),
- ]),
+ createSimpleExpression('_tag'),
+ createBlockStatement([createSimpleExpression('_push(`<${_tag}>`)')]),
),
)
}
if (hasFallthroughAttrs) {
context.pushStatement(
createIfStatement(
- createSimpleExpression('_attrs && _attrs.tag'),
- createBlockStatement([
- createSimpleExpression('_push(`</${_attrs.tag}>`)'),
- ]),
+ createSimpleExpression('_tag'),
+ createBlockStatement([createSimpleExpression('_push(`</${_tag}>`)')]),
),
)
}