diff --git a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts index 8088bbac91..8c8bd70696 100644 --- a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts +++ b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts @@ -138,11 +138,27 @@ export default class InlineComponentWrapper extends Wrapper { const statements: Array = []; const updates: Array = []; + 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: { @@ -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