Siteimprove / alfa

:wheelchair: Suite of open and standards-based tools for performing reliable accessibility conformance testing at scale
MIT License
102 stars 11 forks source link

Fix accessible name calculation bug related to nested `<label>`s #1616

Open rcj-siteimprove opened 1 month ago

rcj-siteimprove commented 1 month ago

A variable was incorrectly being shadowed causing the state to be set incorrectly in some cases. This caused some kind of explosion in the recursion which, if there were enough <label>s inside the outer label (more than 5 I think), would lead to the maximum number of stack frames being exceeded.

In addition, if the number of inner labels was small enough, it would not crash, but the accessible name of the first <input> would be incorrect. This PR fixes that. The names of <input>s inside the inner <label>s are still computed differently than what Chrome computes. It's not completely clear yet, if Chrome is actually implementing the spec and if not, if we should follow chrome or the spec.

Example

<label>
  <input type="checkbox" name="Foo" value="Yes" />Foo
  <br />
  <label><input type="checkbox" name="Bar" value="Yes" />Bar</label>
</label>

In this example the first <input> was getting the computed name of "Foo Foo BarBar" where Chrome would get "Foo Bar". With this PR we are aligned with Chrome for that element.

I also updated some function descriptions with some examples to make it a little clearer what exactly referrer and referred means for <label> and <input>s.

To do

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: cede617f91020747e713e5c8566c2f82eb2def40

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 78 packages | Name | Type | | ------------------------------- | ----- | | @siteimprove/alfa-aria | Patch | | @siteimprove/alfa-act | Patch | | @siteimprove/alfa-affine | Patch | | @siteimprove/alfa-applicative | Patch | | @siteimprove/alfa-array | Patch | | @siteimprove/alfa-bits | Patch | | @siteimprove/alfa-branched | Patch | | @siteimprove/alfa-cache | Patch | | @siteimprove/alfa-callback | Patch | | @siteimprove/alfa-cascade | Patch | | @siteimprove/alfa-clone | Patch | | @siteimprove/alfa-collection | Patch | | @siteimprove/alfa-comparable | Patch | | @siteimprove/alfa-compatibility | Patch | | @siteimprove/alfa-continuation | Patch | | @siteimprove/alfa-css-feature | Patch | | @siteimprove/alfa-css | Patch | | @siteimprove/alfa-device | Patch | | @siteimprove/alfa-dom | Patch | | @siteimprove/alfa-earl | Patch | | @siteimprove/alfa-either | Patch | | @siteimprove/alfa-emitter | Patch | | @siteimprove/alfa-encoding | Patch | | @siteimprove/alfa-equatable | Patch | | @siteimprove/alfa-flags | Patch | | @siteimprove/alfa-fnv | Patch | | @siteimprove/alfa-foldable | Patch | | @siteimprove/alfa-functor | Patch | | @siteimprove/alfa-future | Patch | | @siteimprove/alfa-generator | Patch | | @siteimprove/alfa-graph | Patch | | @siteimprove/alfa-hash | Patch | | @siteimprove/alfa-http | Patch | | @siteimprove/alfa-iana | Patch | | @siteimprove/alfa-iterable | Patch | | @siteimprove/alfa-json-ld | Patch | | @siteimprove/alfa-json | Patch | | @siteimprove/alfa-lazy | Patch | | @siteimprove/alfa-list | Patch | | @siteimprove/alfa-map | Patch | | @siteimprove/alfa-mapper | Patch | | @siteimprove/alfa-math | Patch | | @siteimprove/alfa-media | Patch | | @siteimprove/alfa-monad | Patch | | @siteimprove/alfa-network | Patch | | @siteimprove/alfa-option | Patch | | @siteimprove/alfa-parser | Patch | | @siteimprove/alfa-performance | Patch | | @siteimprove/alfa-predicate | Patch | | @siteimprove/alfa-promise | Patch | | @siteimprove/alfa-record | Patch | | @siteimprove/alfa-rectangle | Patch | | @siteimprove/alfa-reducer | Patch | | @siteimprove/alfa-refinement | Patch | | @siteimprove/alfa-result | Patch | | @siteimprove/alfa-rules | Patch | | @siteimprove/alfa-sarif | Patch | | @siteimprove/alfa-selective | Patch | | @siteimprove/alfa-selector | Patch | | @siteimprove/alfa-sequence | Patch | | @siteimprove/alfa-set | Patch | | @siteimprove/alfa-slice | Patch | | @siteimprove/alfa-string | Patch | | @siteimprove/alfa-style | Patch | | @siteimprove/alfa-table | Patch | | @siteimprove/alfa-test | Patch | | @siteimprove/alfa-thenable | Patch | | @siteimprove/alfa-thunk | Patch | | @siteimprove/alfa-time | Patch | | @siteimprove/alfa-toolchain | Patch | | @siteimprove/alfa-trampoline | Patch | | @siteimprove/alfa-tree | Patch | | @siteimprove/alfa-trilean | Patch | | @siteimprove/alfa-tuple | Patch | | @siteimprove/alfa-url | Patch | | @siteimprove/alfa-wcag | Patch | | @siteimprove/alfa-web | Patch | | @siteimprove/alfa-xpath | Patch |

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