Skip to content

Commit 3898b05

Browse files
committed
Reapply sveltejs#3128 changes to new interfaces.
1 parent c323282 commit 3898b05

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/compiler/compile/render_dom/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,12 @@ export default function dom(
453453
@insert(options.target, this, options.anchor);
454454
}
455455
456+
this.$$.slotted = {};
456457
${(props.length > 0 || uses_props) && b`
458+
for (const key in options.props.$$slots) {
459+
this.$$.slotted[key] = options.props.$$slots[key][0]();
460+
this.$$.slotted[key].c();
461+
}
457462
if (options.props) {
458463
this.$set(options.props);
459464
@flush();

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,12 @@ export default class InlineComponentWrapper extends Wrapper {
401401
}
402402

403403
block.chunks.mount.push(b`
404-
if (${name}) {
404+
if (component.compile_options.customElement) {
405+
block.chunks.mount.push(
406+
@insert(${parent_node || '#target'}, ${name}, ${parent_node ? 'null' : 'anchor'});
407+
)
408+
}
409+
else if (${name}) {
405410
@mount_component(${name}, ${parent_node || '#target'}, ${parent_node ? 'null' : 'anchor'});
406411
}
407412
`);

src/runtime/internal/Component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ if (typeof HTMLElement === 'function') {
174174
// @ts-ignore todo: improve typings
175175
for (const key in this.$$.slotted) {
176176
// @ts-ignore todo: improve typings
177-
this.appendChild(this.$$.slotted[key]);
177+
//this.appendChild(this.$$.slotted[key]);
178+
this.$$.slotted[key].m(this, null);
178179
}
179180
}
180181

@@ -183,6 +184,11 @@ if (typeof HTMLElement === 'function') {
183184
}
184185

185186
$destroy() {
187+
// @ts-ignore todo: improve typings
188+
for (const key in this.$$.slotted) {
189+
// @ts-ignore todo: improve typings
190+
this.$$.slotted[key].d();
191+
}
186192
destroy_component(this, 1);
187193
this.$destroy = noop;
188194
}

0 commit comments

Comments
 (0)