0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-30 08:56:14 +01:00

fix slot block lineage - fixes #2124

This commit is contained in:
Richard Harris 2019-02-21 23:34:27 -05:00
parent c494c05ebf
commit 24e09efec1
4 changed files with 21 additions and 2 deletions

View File

@ -132,7 +132,7 @@ export default class ElementWrapper extends Wrapper {
const name = attribute.getStaticValue();
if (!(owner as InlineComponentWrapper).slots.has(name)) {
const child_block = block.parent.child({
const child_block = block.child({
comment: createDebuggingComment(node, this.renderer.component),
name: this.renderer.component.getUniqueName(`create_${sanitize(name)}_slot`)
});
@ -205,7 +205,8 @@ export default class ElementWrapper extends Wrapper {
block.parent.addDependencies(block.dependencies);
// appalling hack
block.parent.wrappers.splice(block.parent.wrappers.indexOf(this), 1);
const index = block.parent.wrappers.indexOf(this);
block.parent.wrappers.splice(index, 1);
block.wrappers.push(this);
}
}

View File

@ -0,0 +1 @@
<slot name="name"></slot>

View File

@ -0,0 +1,6 @@
export default {
html: `
<span slot="name">Hello</span>
<span slot="name">world</span>
`
};

View File

@ -0,0 +1,11 @@
<script>
import Nested from './Nested.svelte';
</script>
<Nested>
<span slot="name">Hello</span>
</Nested>
<Nested>
<span slot="name">world</span>
</Nested>