diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts
index 9fdaa0cbaaa0..37684d984cce 100644
--- a/src/compiler/compile/render_dom/index.ts
+++ b/src/compiler/compile/render_dom/index.ts
@@ -460,15 +460,22 @@ export default function dom(
${dev_props_check}
if (options) {
+ this.$$.slotted = {};
+
if (options.target) {
@insert(options.target, this, options.anchor);
}
- ${(props.length > 0 || uses_props) && deindent`
if (options.props) {
+ for (const key in options.props.$$slots) {
+ const ctx = options.props.$$scope ? options.props.$$scope.ctx : {};
+ this.$$.slotted[key] = options.props.$$slots[key][0](ctx);
+ this.$$.slotted[key].c();
+ }
+ ${(props.length > 0 || uses_props) && deindent`
this.$set(options.props);
- @flush();
- }`}
+ @flush();`}
+ }
}
}
diff --git a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts
index 9cff40ecbb50..38a0f94e1488 100644
--- a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts
+++ b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts
@@ -449,9 +449,15 @@ export default class InlineComponentWrapper extends Wrapper {
);
}
- block.builders.mount.add_line(
- `@mount_component(${name}, ${parent_node || '#target'}, ${parent_node ? 'null' : 'anchor'});`
- );
+ if (component.compile_options.customElement) {
+ block.builders.mount.add_line(
+ `@insert(${ parent_node || '#target'}, ${name}, ${parent_node ? 'null' : 'anchor'});`
+ )
+ } else {
+ block.builders.mount.add_line(
+ `@mount_component(${name}, ${parent_node || '#target'}, ${parent_node ? 'null' : 'anchor'});`
+ );
+ }
block.builders.intro.add_block(deindent`
@transition_in(${name}.$$.fragment, #local);
diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts
index 9221a683b851..929dc381b092 100644
--- a/src/runtime/internal/Component.ts
+++ b/src/runtime/internal/Component.ts
@@ -146,7 +146,7 @@ if (typeof HTMLElement !== 'undefined') {
// @ts-ignore todo: improve typings
for (const key in this.$$.slotted) {
// @ts-ignore todo: improve typings
- this.appendChild(this.$$.slotted[key]);
+ this.$$.slotted[key].m(this, null);
}
}
@@ -155,6 +155,11 @@ if (typeof HTMLElement !== 'undefined') {
}
$destroy() {
+ // @ts-ignore todo: improve typings
+ for (const key in this.$$.slotted) {
+ // @ts-ignore todo: improve typings
+ this.$$.slotted[key].d();
+ }
destroy_component(this, 1);
this.$destroy = noop;
}
diff --git a/test/custom-elements/index.js b/test/custom-elements/index.js
index 9255d33c0ef4..d6468844bfc1 100644
--- a/test/custom-elements/index.js
+++ b/test/custom-elements/index.js
@@ -105,8 +105,9 @@ describe('custom-elements', function() {
const page = await browser.newPage();
- page.on('console', (type, ...args) => {
- console[type](...args);
+ page.on('console', msg => {
+ for (let i = 0; i < msg.args().length; ++i)
+ console[msg.type()](`${i}: ${msg.args()[i]}`);
});
try {
diff --git a/test/custom-elements/samples/nested-slots/Block.svelte b/test/custom-elements/samples/nested-slots/Block.svelte
new file mode 100644
index 000000000000..159e9f4de9de
--- /dev/null
+++ b/test/custom-elements/samples/nested-slots/Block.svelte
@@ -0,0 +1,3 @@
+