mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-29 08:32:05 +01:00
assign elements to correct block when slots are involved - fixes #2031
This commit is contained in:
parent
89b00c7d30
commit
5c7fdf4ad2
@ -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(
|
||||
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
import Two from './Two.svelte';
|
||||
</script>
|
||||
|
||||
<Two>
|
||||
<div slot="b">
|
||||
<div>
|
||||
<slot name="a"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</Two>
|
@ -0,0 +1 @@
|
||||
<slot name="b"></slot>
|
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
html: `
|
||||
<div slot="b">
|
||||
<div>
|
||||
<div slot="a">a</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import One from './One.svelte';
|
||||
</script>
|
||||
|
||||
<One>
|
||||
<div slot="a">a</div>
|
||||
</One>
|
Loading…
Reference in New Issue
Block a user