Conversation
…t whitespace-separated role lists
Two changes, shared root cause (both deal with role-token normalisation).
1. Case-insensitive role matching. Per HTML-AAM, ARIA role tokens
compare as ASCII-case-insensitive. Before: <div role="COMBOBOX">
was silently accepted because "COMBOBOX" didn't match "combobox" in
aria-query. Now: lowercase before lookup.
2. Whitespace-separated role fallback lists. Per ARIA 1.2 §5.4, a role
attribute may list multiple tokens to express a fallback; a UA picks
the first one it recognises. Before: role="combobox listbox" was
treated as one opaque string, aria-query returned undefined, and
the rule skipped silently. Now: split on whitespace, check against
the first recognised role's required attributes (matching jsx-a11y).
Helpers renamed to plural forms (getStaticRolesFromElement,
getStaticRolesFromMustache) and getMissingRequiredAttributes now
returns { role, missing } so the reporter can use the actually-checked
role in the error message.
Four new tests cover the two cases (valid + invalid of each).
🏎️ Benchmark Comparison
Full mitata output |
…back semantics The previous comment said this matched jsx-a11y, but jsx-a11y validates every recognised role token while we check only the first recognised role per ARIA role-fallback semantics. Update the comment to reflect the PR description's stated behavior.
…er cases
Translates 33 cases from peer-plugin rules:
- jsx-a11y role-has-required-aria-props
- vuejs-accessibility role-has-required-aria-props
- @angular-eslint/template role-has-required-aria
- lit-a11y role-has-required-aria-attrs
Fixture documents parity after this fix:
- Case-insensitive role comparison (<div role="COMBOBOX"> flagged).
- Whitespace-separated roles: first recognised token is validated
(ARIA 1.2 §4.1 role-fallback semantics). Divergence from jsx-a11y,
which validates every recognised token; documented inline.
The semantic input+role exception (input[type=checkbox] role=switch)
remains flagged here — that fix is on a separate branch.
Owner
Author
|
Moved upstream to ember-cli#2728. See that PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related fixes (shared root cause — both deal with role-token normalisation).
1. Case-insensitive role comparison
<div role="COMBOBOX">was silently accepted —roles.get("COMBOBOX")returns undefined inaria-query, so the rule skipped the check entirely.Fix: lowercase the role value before the lookup.
2. Whitespace-separated role fallback lists
roleattribute may list multiple tokens to express a fallback; user agents pick the first they recognise.role="combobox listbox"was treated as one opaque string.aria-queryreturned undefined, the rule skipped silently, and<div role="combobox listbox">withoutaria-expanded+aria-controlswasn't flagged.Fix: split on whitespace, validate the first recognised role per ARIA §4.1 role-fallback semantics. This diverges from jsx-a11y, which validates every recognised token rather than only the first.
Helpers renamed to plural forms (
getStaticRolesFromElement,getStaticRolesFromMustache).getMissingRequiredAttributesnow returns{ role, missing }so the reporter can cite the actually-checked role in the error message.Four new tests cover both fixes (valid + invalid of each).
Prior art
role-has-required-aria-props.toLowerCase().split(' ')of the role value; filters to recognised tokens, then validates every one.role-has-required-aria-propsrole-has-required-ariaaria-query'sroles.get.role-has-required-aria-attrsroles.get.Upstream
ember-template-lint@7.9.3has both gaps.