mirror of https://github.com/sveltejs/svelte
Merge pull request #3171 from sveltejs/gh-3140
Pass context used in bindings down to slotspull/3192/head
commit
8203c22f63
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
export let items;
|
||||
</script>
|
||||
|
||||
<div>
|
||||
{#each items as item, index}
|
||||
<slot {index}/>
|
||||
{/each}
|
||||
</div>
|
@ -0,0 +1,26 @@
|
||||
export default {
|
||||
html: `
|
||||
<div>
|
||||
<label>1: <input></label>
|
||||
<label>2: <input></label>
|
||||
<label>3: <input></label>
|
||||
</div>
|
||||
`,
|
||||
|
||||
ssrHtml: `
|
||||
<div>
|
||||
<label>1: <input value="a"></label>
|
||||
<label>2: <input value="b"></label>
|
||||
<label>3: <input value="c"></label>
|
||||
</div>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const inputs = target.querySelectorAll('input');
|
||||
|
||||
inputs[2].value = 'd';
|
||||
await inputs[2].dispatchEvent(new window.Event('input'));
|
||||
|
||||
assert.deepEqual(component.letters, ['a', 'b', 'd']);
|
||||
}
|
||||
};
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
import Nested from './Nested.svelte';
|
||||
|
||||
export let letters = ['a', 'b', 'c'];
|
||||
</script>
|
||||
|
||||
<Nested items={letters} let:index>
|
||||
<label>
|
||||
{index + 1}: <input bind:value={letters[index]}>
|
||||
</label>
|
||||
</Nested>
|
Loading…
Reference in new issue