Skip to content

Commit

Permalink
remove slot that does not render anything
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed Mar 3, 2020
1 parent d802c3b commit 1b4a93b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,27 @@ export default class InlineComponentWrapper extends Wrapper {
const statements: Array<Node | Node[]> = [];
const updates: Array<Node | Node[]> = [];

if (this.fragment) {
this.renderer.add_to_context('$$scope', true);
const default_slot = this.slots.get('default');

this.fragment.nodes.forEach((child) => {
child.render(default_slot.block, null, x`#nodes` as unknown as Identifier);
});
}

let props;
const name_changes = block.get_unique_name(`${name.name}_changes`);

const uses_spread = !!this.node.attributes.find(a => a.is_spread);

// removing empty slot
for (const slot of this.slots.keys()) {
if (!this.slots.get(slot).block.has_content()) {
this.slots.delete(slot);
}
}

const initial_props = this.slots.size > 0
? [
p`$$slots: {
Expand Down Expand Up @@ -172,15 +188,6 @@ export default class InlineComponentWrapper extends Wrapper {
}
}

if (this.fragment) {
this.renderer.add_to_context('$$scope', true);
const default_slot = this.slots.get('default');

this.fragment.nodes.forEach((child) => {
child.render(default_slot.block, null, x`#nodes` as unknown as Identifier);
});
}

if (component.compile_options.dev) {
// TODO this is a terrible hack, but without it the component
// will complain that options.target is missing. This would
Expand Down

0 comments on commit 1b4a93b

Please sign in to comment.