Repository navigation
Description
Summary
a11y/form-field-multiple-labels counts a <label> twice when it both wraps the input and references it with for=. The input has exactly one associated label (input.labels.length === 1), but squirrel reports "2 labels". axe-core's form-field-multiple-labels does not flag this pattern.
This is the default markup of Shopify Dawn-based product forms (variant radios), so it fires on every product page of such shops.
Minimal repro
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Gift card amount selection form test page</title></head>
<body><main><h1>Gift card</h1>
<form><fieldset><legend>Amount</legend>
<label for="a"><input type="radio" name="amt" id="a" value="50"> 50</label>
<label for="b"><input type="radio" name="amt" id="b" value="100"> 100</label>
</fieldset></form></main></body></html>python3 -m http.server 8765
squirrel audit http://localhost:8765/ --http -f json -o out.jsonActual
{"name":"form-field-multiple-labels","status":"warn","message":"2 input(s) with multiple labels","items":[{"id":"amt (2 labels)"}]}Expected
No finding: each input has one label element. Associated labels should be collected as a set of label elements (HTMLInputElement.labels semantics), so a label that both wraps and references the same input counts once.
Controls (same version)
| Markup | Result | Correct |
|---|---|---|
<label><input></label> (wrap only) |
pass | yes |
<label for="x">X</label><input id="x"> (for only) |
pass | yes |
two <label for="y"> + <input id="y"> |
warn, 1 input | yes |
<label for="a"><input id="a"></label> (wrap + for) |
warn, 2 labels | no |
Possibly the same counting exists in sibling label rules; worth a look.
Version
squirrel 0.0.138 (macOS arm64), --http mode. Seen in production on www.bowlio.com product pages.
Triage
Confirmed against current main. packages/rules/src/a11y/form-field-multiple-labels.ts adds the count of label[for="<id>"] matches and then adds one more when input.closest("label") exists. A label that both wraps the input and points at it with for= is counted by both paths, so one label element reads as two.
Acceptance Criteria
-
<label for="a"><input id="a"></label>produces noform-field-multiple-labelsfinding. - The repro page above passes the rule.
- Two distinct label elements on one input (two
<label for>or one wrapping plus onefor) still warn, with an accurate label count. - The wrap-only and for-only controls still pass.
- A regression test covers the wrap-plus-for case, and the rule docs mention it if they describe label counting.
Activity
fix(rules): count label elements in form-field-multiple-labels, skip …
nc9 commentedon Oct 30, 2026
Fixed in v0.0.142 (1ea94aae), via the stacked release PR #1331.