Skip to content

Commit 1b4a93b

Browse files
committed
remove slot that does not render anything
1 parent d802c3b commit 1b4a93b

File tree

1 file changed

+16
-9
lines changed
  • src/compiler/compile/render_dom/wrappers/InlineComponent

1 file changed

+16
-9
lines changed

src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,27 @@ export default class InlineComponentWrapper extends Wrapper {
138138
const statements: Array<Node | Node[]> = [];
139139
const updates: Array<Node | Node[]> = [];
140140

141+
if (this.fragment) {
142+
this.renderer.add_to_context('$$scope', true);
143+
const default_slot = this.slots.get('default');
144+
145+
this.fragment.nodes.forEach((child) => {
146+
child.render(default_slot.block, null, x`#nodes` as unknown as Identifier);
147+
});
148+
}
149+
141150
let props;
142151
const name_changes = block.get_unique_name(`${name.name}_changes`);
143152

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

155+
// removing empty slot
156+
for (const slot of this.slots.keys()) {
157+
if (!this.slots.get(slot).block.has_content()) {
158+
this.slots.delete(slot);
159+
}
160+
}
161+
146162
const initial_props = this.slots.size > 0
147163
? [
148164
p`$$slots: {
@@ -172,15 +188,6 @@ export default class InlineComponentWrapper extends Wrapper {
172188
}
173189
}
174190

175-
if (this.fragment) {
176-
this.renderer.add_to_context('$$scope', true);
177-
const default_slot = this.slots.get('default');
178-
179-
this.fragment.nodes.forEach((child) => {
180-
child.render(default_slot.block, null, x`#nodes` as unknown as Identifier);
181-
});
182-
}
183-
184191
if (component.compile_options.dev) {
185192
// TODO this is a terrible hack, but without it the component
186193
// will complain that options.target is missing. This would

0 commit comments

Comments
 (0)