|
|
|
@ -9,7 +9,6 @@ import { add_const_tags, add_const_tags_context } from './shared/add_const_tags.
|
|
|
|
|
|
|
|
|
|
|
|
/** @extends Wrapper */
|
|
|
|
/** @extends Wrapper */
|
|
|
|
export default class SlotTemplateWrapper extends Wrapper {
|
|
|
|
export default class SlotTemplateWrapper extends Wrapper {
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {import('../../nodes/SlotTemplate.js').default} */
|
|
|
|
/** @type {import('../../nodes/SlotTemplate.js').default} */
|
|
|
|
node;
|
|
|
|
node;
|
|
|
|
|
|
|
|
|
|
|
|
@ -47,33 +46,35 @@ export default class SlotTemplateWrapper extends Wrapper {
|
|
|
|
this.renderer.blocks.push(this.block);
|
|
|
|
this.renderer.blocks.push(this.block);
|
|
|
|
const seen = new Set(lets.map((l) => l.name.name));
|
|
|
|
const seen = new Set(lets.map((l) => l.name.name));
|
|
|
|
this.parent.node.lets.forEach((l) => {
|
|
|
|
this.parent.node.lets.forEach((l) => {
|
|
|
|
if (!seen.has(l.name.name))
|
|
|
|
if (!seen.has(l.name.name)) lets.push(l);
|
|
|
|
lets.push(l);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.parent.set_slot(slot_template_name, get_slot_definition(this.block, scope, lets));
|
|
|
|
this.parent.set_slot(slot_template_name, get_slot_definition(this.block, scope, lets));
|
|
|
|
this.fragment = new FragmentWrapper(renderer, this.block, node.type === 'SlotTemplate' ? node.children : [node], this, strip_whitespace, next_sibling);
|
|
|
|
this.fragment = new FragmentWrapper(
|
|
|
|
|
|
|
|
renderer,
|
|
|
|
|
|
|
|
this.block,
|
|
|
|
|
|
|
|
node.type === 'SlotTemplate' ? node.children : [node],
|
|
|
|
|
|
|
|
this,
|
|
|
|
|
|
|
|
strip_whitespace,
|
|
|
|
|
|
|
|
next_sibling
|
|
|
|
|
|
|
|
);
|
|
|
|
this.block.parent.add_dependencies(this.block.dependencies);
|
|
|
|
this.block.parent.add_dependencies(this.block.dependencies);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
this.fragment.render(this.block, null, /** @type {import('estree').Identifier} */ (x `#nodes`));
|
|
|
|
this.fragment.render(this.block, null, /** @type {import('estree').Identifier} */ (x`#nodes`));
|
|
|
|
if (this.node.const_tags.length > 0) {
|
|
|
|
if (this.node.const_tags.length > 0) {
|
|
|
|
this.render_get_context();
|
|
|
|
this.render_get_context();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render_get_context() {
|
|
|
|
render_get_context() {
|
|
|
|
const get_context = this.block.renderer.component.get_unique_name('get_context');
|
|
|
|
const get_context = this.block.renderer.component.get_unique_name('get_context');
|
|
|
|
this.block.renderer.blocks.push(b `
|
|
|
|
this.block.renderer.blocks.push(b`
|
|
|
|
function ${get_context}(#ctx) {
|
|
|
|
function ${get_context}(#ctx) {
|
|
|
|
${add_const_tags(this.block, this.node.const_tags, '#ctx')}
|
|
|
|
${add_const_tags(this.block, this.node.const_tags, '#ctx')}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
this.block.chunks.declarations.push(b `${get_context}(#ctx)`);
|
|
|
|
this.block.chunks.declarations.push(b`${get_context}(#ctx)`);
|
|
|
|
if (this.block.has_update_method) {
|
|
|
|
if (this.block.has_update_method) {
|
|
|
|
this.block.chunks.update.unshift(b `${get_context}(#ctx)`);
|
|
|
|
this.block.chunks.update.unshift(b`${get_context}(#ctx)`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|