mirror of https://github.com/sveltejs/svelte
Merge pull request #2419 from sveltejs/gh-2320
Expose default slot values to named slotspull/2420/head
commit
158ce2eea1
@ -0,0 +1,17 @@
|
||||
<script>
|
||||
import { onDestroy } from 'svelte';
|
||||
|
||||
let count = 0;
|
||||
|
||||
function increment() {
|
||||
count += 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<slot {count}></slot>
|
||||
<slot name="foo" {count}></slot>
|
||||
<slot name="bar"></slot>
|
||||
|
||||
<button on:click={increment}>+1</button>
|
||||
</div>
|
@ -0,0 +1,25 @@
|
||||
export default {
|
||||
html: `
|
||||
<div>
|
||||
<p>count in default slot: 0</p>
|
||||
<p slot="foo">count in foo slot: 0</p>
|
||||
<p slot="bar">count in bar slot: 0</p>
|
||||
<button>+1</button>
|
||||
</div>
|
||||
`,
|
||||
|
||||
async test({ assert, target, window }) {
|
||||
const button = target.querySelector('button');
|
||||
|
||||
await button.dispatchEvent(new window.MouseEvent('click'));
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<div>
|
||||
<p>count in default slot: 1</p>
|
||||
<p slot="foo">count in foo slot: 1</p>
|
||||
<p slot="bar">count in bar slot: 1</p>
|
||||
<button>+1</button>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<script>
|
||||
import Nested from './Nested.svelte';
|
||||
</script>
|
||||
|
||||
<Nested let:count>
|
||||
<p>
|
||||
count in default slot: {count}
|
||||
</p>
|
||||
|
||||
<p slot="foo" let:count>
|
||||
count in foo slot: {count}
|
||||
</p>
|
||||
|
||||
<p slot="bar">
|
||||
count in bar slot: {count}
|
||||
</p>
|
||||
</Nested>
|
Loading…
Reference in new issue