show an extra bind checked error when a radio type

pull/16874/head
yuki0418 11 months ago
parent 9e5fe33b9c
commit 23ecd3db29

@ -95,7 +95,7 @@ Since 5.6.0, if an `<input>` has a `defaultValue` and is part of a form, it will
## `<input bind:checked>`
Checkbox can be bound with `bind:checked`:
Checkbox inputs can be bound with `bind:checked`:
```svelte
<label>

@ -70,7 +70,7 @@ export function BindDirective(node, context) {
e.bind_invalid_target(
node,
node.name,
`<input type="checkbox"> - for <input type="radio">, use 'group' binding`
`<input type="checkbox">${type?.value[0].data === 'radio' ? ` for <input type="radio">, use 'group' binding` : ''}`
);
}

@ -1,7 +1,7 @@
[
{
"code": "bind_invalid_target",
"message": "`bind:checked` can only be used with <input type=\"checkbox\"> - for <input type=\"radio\">, use 'group' binding",
"message": "`bind:checked` can only be used with <input type=\"checkbox\">",
"start": {
"line": 5,
"column": 7

@ -0,0 +1,14 @@
[
{
"code": "bind_invalid_target",
"message": "`bind:checked` can only be used with <input type=\"checkbox\"> — for <input type=\"radio\">, use 'group' binding",
"start": {
"line": 5,
"column": 20
},
"end": {
"line": 5,
"column": 38
}
}
]

@ -0,0 +1,5 @@
<script>
let foo;
</script>
<input type="radio" bind:checked={foo}>
Loading…
Cancel
Save