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

Merge pull request #2125 from sveltejs/gh-2124

fix slot block lineage
This commit is contained in:
Rich Harris 2019-02-22 07:58:40 -05:00 committed by GitHub
commit b1f3514e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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>