-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Pass context used in bindings down to slots
- Loading branch information
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/component-slot-let-in-binding/Nested.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script> | ||
export let items; | ||
</script> | ||
|
||
<div> | ||
{#each items as item, index} | ||
<slot {index}/> | ||
{/each} | ||
</div> |
26 changes: 26 additions & 0 deletions
26
test/runtime/samples/component-slot-let-in-binding/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']); | ||
} | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/component-slot-let-in-binding/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |