dequelabs / dequelabs/axe-core

Support fallback roles

Open
#3,768 3 comments 0 reactions 0 assignees View on GitHub
commons core fix rules support
Dominant language
JavaScript
Stars
7.5k
Forks
933
Avg merge
2d 13h
Merged PRs (30d)
29

Description

In axe-core 4.5 we stopped failing elements that use fallback roles in the role attribute. However many places in axe-core still assume fallback roles are not allowed. For example many rule selectors do something like `[role="button"]` to select elements with an explicit button role. That wouldn't work for elements with for example `role="button img"`, which will not match.

I think we need to do things for this ticket;

1. Go through the code base, and replace all uses of `.getAttribute('role')` / `.attr('role')` with `aria.getExplicitRole()`

2. The `fallback` flag of `aria.getRole()` and its related methods needs to be set to true, and tests need to be added in relevant places that are impacted by this.

3. Replace rule selectors that use `[role="??"]` with something that uses the explicit role. There are lots of ways we could do this, so we need to figure out what's the best way to do this first. Some ideas include allowing a custom `::axe/explicitRole('button')` selector, allowing the matches property to use `axe.commons.matches()` objects, or maybe adding an `option` object for matcher methods, and add an `explicit-role-matches` method.

Contributor guide

Open the contributing guide

Research direction

Start by searching the codebase for .getAttribute('role'), .attr('role'), aria.getRole(), and selectors using [role="??"]. Read the related aria and rule tests before deciding how explicit-role matching should work; done means fallback roles are handled consistently, selectors use explicit roles, and impacted tests cover the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
accessibility
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.