Skip to content

Commit bff608b

Browse files
committed
fix: prevent a11y_label_has_associated_control false positive for component in <label>
1 parent 7295fac commit bff608b

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

.changeset/swift-rats-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: prevent `a11y_label_has_associated_control` false positive for component in `<label>`

packages/svelte/src/compiler/phases/2-analyze/a11y.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ function check_element(node, state) {
10861086
if (
10871087
node.type === 'SvelteElement' ||
10881088
node.type === 'SlotElement' ||
1089+
node.type === 'Component' ||
10891090
(node.type === 'RegularElement' &&
10901091
(a11y_labelable.includes(node.name) || node.name === 'slot'))
10911092
) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<script>
2+
import Component from './component.svelte'
3+
</script>
4+
15
<label>
26
<slot />
37
</label>
8+
9+
<label>
10+
<Component />
11+
</label>

0 commit comments

Comments
 (0)