fix: prevent `a11y_label_has_associated_control` false positive for component in `<label>` (#12119)

* fix: prevent `a11y_label_has_associated_control` false positive for component in `<label>`

* fix render tags as well

* Update .changeset/swift-rats-sing.md

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
pull/12132/head
wackbyte 3 months ago committed by GitHub
parent 965c12f633
commit 5b60a0e6ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: prevent `a11y_label_has_associated_control` false positive for component or render tag in `<label>`

@ -1086,6 +1086,8 @@ function check_element(node, state) {
if (
node.type === 'SvelteElement' ||
node.type === 'SlotElement' ||
node.type === 'Component' ||
node.type === 'RenderTag' ||
(node.type === 'RegularElement' &&
(a11y_labelable.includes(node.name) || node.name === 'slot'))
) {

@ -1,3 +1,11 @@
<script>
import Component from './component.svelte'
</script>
<label>
<slot />
</label>
<label>
<Component />
</label>

@ -0,0 +1,7 @@
<script>
import Component from './component.svelte'
</script>
<label>
{@render x()}
</label>
Loading…
Cancel
Save