fix: update error message to clarify usage with radio inputs#16874
fix: update error message to clarify usage with radio inputs#16874Rich-Harris merged 4 commits intosveltejs:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 926f9a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| e.bind_invalid_target( | ||
| node, | ||
| node.name, | ||
| `<input type="checkbox"> - for <input type="radio">, use 'group' binding` |
There was a problem hiding this comment.
Please let me know if there are better message.
| ## `<input bind:checked>` | ||
|
|
||
| Checkbox and radio inputs can be bound with `bind:checked`: | ||
| Checkbox can be bound with `bind:checked`: |
There was a problem hiding this comment.
| Checkbox can be bound with `bind:checked`: | |
| Checkbox inputs can be bound with `bind:checked`: |
| e.bind_invalid_target( | ||
| node, | ||
| node.name, | ||
| `<input type="checkbox"> - for <input type="radio">, use 'group' binding` |
There was a problem hiding this comment.
In svelte 4 the last part was only in the error message if you tried to use it with type="radio".
Not sure if we want to keep it like that.
| `<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` : ''}` |
There was a problem hiding this comment.
Modified.
I have a same experience of using bind:checked with radio input.
At that time, I went to the official doc and realized we should use group bind.
From that my experience, keeping extra message is friendly for developers but it is not necessary.
|
closes #16870
Description
Change error message for radio input checked binding.
Before:
After:
Docs screenshot
Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.packages/svelte/src, add a changeset (npx changeset).Tests and linting
pnpm testand lint the project withpnpm lint