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

pull/8569/head
Simon Holthausen 3 years ago
parent f468b00315
commit 9ed03bcd28

@ -10,34 +10,29 @@ import { get_slot_scope } from './shared/get_slot_scope';
* }} options * }} options
*/ */
export default function (node, renderer, options) { export default function (node, renderer, options) {
const slot_data = get_slot_data(node.values); const slot_data = get_slot_data(node.values);
const slot = node.get_static_attribute_value('slot'); const slot = node.get_static_attribute_value('slot');
const nearest_inline_component = node.find_nearest(/InlineComponent/); const nearest_inline_component = node.find_nearest(/InlineComponent/);
if (slot && nearest_inline_component) { if (slot && nearest_inline_component) {
renderer.push(); renderer.push();
} }
renderer.push(); renderer.push();
renderer.render(node.children, options); renderer.render(node.children, options);
const result = renderer.pop(); const result = renderer.pop();
renderer.add_expression(x ` renderer.add_expression(x`
#slots.${node.slot_name} #slots.${node.slot_name}
? #slots.${node.slot_name}(${slot_data}) ? #slots.${node.slot_name}(${slot_data})
: ${result} : ${result}
`); `);
if (slot && nearest_inline_component) { if (slot && nearest_inline_component) {
const lets = node.lets; const lets = node.lets;
const seen = new Set(lets.map((l) => l.name.name)); const seen = new Set(lets.map((l) => l.name.name));
nearest_inline_component.lets.forEach((l) => { nearest_inline_component.lets.forEach((l) => {
if (!seen.has(l.name.name)) if (!seen.has(l.name.name)) lets.push(l);
lets.push(l); });
}); options.slot_scopes.set(slot, {
options.slot_scopes.set(slot, { input: get_slot_scope(node.lets),
input: get_slot_scope(node.lets), output: renderer.pop()
output: renderer.pop() });
}); }
}
} }

Loading…
Cancel
Save