0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-29 08:32:05 +01:00

Merge pull request #2097 from sveltejs/gh-2031-with-fix

assign elements to correct block when slots are involved
This commit is contained in:
Rich Harris 2019-02-17 15:23:55 -04:00 committed by GitHub
commit 47ab23c1de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 3 deletions

View File

@ -203,6 +203,10 @@ export default class ElementWrapper extends Wrapper {
if (this.slot_block) {
block.parent.addDependencies(block.dependencies);
// appalling hack
block.wrappers.splice(block.wrappers.indexOf(this), 1);
this.slot_block.wrappers.push(this);
}
}
@ -216,13 +220,13 @@ export default class ElementWrapper extends Wrapper {
if (this.node.name === 'noscript') return;
const node = this.var;
const nodes = parentNodes && block.getUniqueName(`${this.var}_nodes`) // if we're in unclaimable territory, i.e. <head>, parentNodes is null
if (this.slot_block) {
block = this.slot_block;
}
const node = this.var;
const nodes = parentNodes && block.getUniqueName(`${this.var}_nodes`) // if we're in unclaimable territory, i.e. <head>, parentNodes is null
block.addVariable(node);
const renderStatement = this.getRenderStatement();
block.builders.create.addLine(

View File

@ -0,0 +1,11 @@
<script>
import Two from './Two.svelte';
</script>
<Two>
<div slot="b">
<div>
<slot name="a"></slot>
</div>
</div>
</Two>

View File

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

View File

@ -0,0 +1,9 @@
export default {
html: `
<div slot="b">
<div>
<div slot="a">a</div>
</div>
</div>
`
};

View File

@ -0,0 +1,7 @@
<script>
import One from './One.svelte';
</script>
<One>
<div slot="a">a</div>
</One>