Lint and format src/compiler/compile/render_ssr/handlers/IfBlock.js

pull/8569/head
Simon Holthausen 3 years ago
parent b8b2b58c4e
commit ac034d50ec

@ -7,25 +7,20 @@ import { get_const_tags } from './shared/get_const_tags.js';
* @param {import('../Renderer.js').RenderOptions} options
*/
export default function (node, renderer, options) {
const condition = node.expression.node;
renderer.push();
renderer.render(node.children, options);
const condition = node.expression.node;
renderer.push();
renderer.render(node.children, options);
/** @type {import('estree').Node} */
let consequent = renderer.pop();
if (node.const_tags.length > 0)
consequent = x `(() => { ${get_const_tags(node.const_tags)}; return ${consequent} })()`;
renderer.push();
if (node.else)
renderer.render(node.else.children, options);
/** @type {import('estree').Node} */
let consequent = renderer.pop();
if (node.const_tags.length > 0)
consequent = x`(() => { ${get_const_tags(node.const_tags)}; return ${consequent} })()`;
renderer.push();
if (node.else) renderer.render(node.else.children, options);
/** @type {import('estree').Node} */
let alternate = renderer.pop();
if (node.else && node.else.const_tags.length > 0)
alternate = x `(() => { ${get_const_tags(node.else.const_tags)}; return ${alternate} })()`;
renderer.add_expression(x `${condition} ? ${consequent} : ${alternate}`);
/** @type {import('estree').Node} */
let alternate = renderer.pop();
if (node.else && node.else.const_tags.length > 0)
alternate = x`(() => { ${get_const_tags(node.else.const_tags)}; return ${alternate} })()`;
renderer.add_expression(x`${condition} ? ${consequent} : ${alternate}`);
}

Loading…
Cancel
Save