Move notes on spread attributes with bind:group to spread attributes section

pull/4832/head
Daniel Imfeld 5 years ago
parent 2276a49fbc
commit ab977b9f7c

@ -121,6 +121,9 @@ An element or component can have multiple spread attributes, interspersed with r
<input {...$$restProps}>
```
> The `value` attribute of an `input` element or its children `option` elements must not be set with spread attributes when using `bind:group` or `bind:checked`. Svelte needs to see the element's `value` directly in the markup in this case so that it can link it to the bound variable.
---
### Text expressions
@ -677,27 +680,6 @@ Inputs that work together can use `bind:group`.
<input type="checkbox" bind:group={fillings} value="Guac (extra)">
```
---
The Svelte compiler must be able to detect the `value` attribute for `bind:group` to work properly.
This example uses spread attributes to set the `value` of each checkbox, but it will *not* work since the compiler can not see the `value` attribute.
```sv
<script>
let tortilla = 'Plain';
let tortillaInputs = [
{ value: 'Plain', style: 'color:silver' },
{ value: 'Whole wheat', style: 'color:wheat' },
{ value: 'Spinach', style: 'color:lightgreen' },
];
</script>
{#each tortillaInputs as props}
<input type="radio" bind:group={tortilla} {...props}>
{/each}
```
#### [bind:this](bind_element)
```sv

Loading…
Cancel
Save