[A11Y-12318] Add SIA-R120. - #2175
Conversation
🦋 Changeset detectedLatest commit: bd28ed6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 76 packages
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 |
There was a problem hiding this comment.
🟡 Changes recommended
Duplicate tokens and keys across separate documents can currently produce false failures.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds stable rule R120 to detect duplicate HTML access keys.
Changes:
- Implements duplicate-key detection and diagnostics.
- Registers R120 and adds comprehensive rule tests.
- Adds a minor changeset.
File summaries
| File | Description |
|---|---|
.changeset/lucky-keys-listen.md |
Documents R120. |
packages/alfa-rules/src/rules.ts |
Exports R120. |
packages/alfa-rules/src/sia-r120/rule.ts |
Implements the rule. |
packages/alfa-rules/src/tsconfig.json |
Includes the rule source. |
packages/alfa-rules/test/sia-r120/rule.spec.tsx |
Tests rule behavior. |
packages/alfa-rules/test/tsconfig.json |
Includes the rule tests. |
Review details
Suppressed comments (1)
packages/alfa-rules/src/sia-r120/rule.ts:76
Attribute.tokens()preserves repeated tokens, soaccesskey="a a"inserts this same element twice into the array. Thelength > 1check then reports that “more than one element” declaresa, even though there is no other element. Deduplicate each element's normalized token sequence before building and querying the map.
attribute.tokens().map((token) => token.toLowerCase()),
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| requirements: [BestPractice.of("accesskey-unique")], | ||
| tags: [Scope.Page, Stability.Stable], | ||
| evaluate({ device, document }) { | ||
| const elements = getElementDescendants(document, Node.fullTree) |
There was a problem hiding this comment.
@copilot you mentioned "access keys are scoped to their individual Document." and that ", matching keys in a parent document and an <iframe> are incorrectly reported as competing". Please provide the link to online documentation where it has been mentioned that the keys in a parent document and an <iframe> must be unique with no overlap across.
There was a problem hiding this comment.
I couldn’t find a source that explicitly says a parent document and an <iframe> may or may not reuse the same accesskey. The references I was relying on were the HTML Standard’s accesskey section and the browsing-context/document model:
- https://html.spec.whatwg.org/multipage/interaction.html#the-accesskey-attribute
- https://html.spec.whatwg.org/multipage/document-sequences.html#browsing-context
So my earlier note was an inference from those sections, not a directly quoted requirement.
Description
Add R120 to identify whether a document includes elements with duplicate access keys.
Jira Ticket
https://siteimprove-wgs.atlassian.net/browse/A11Y-12318