Skip to content

Support fallback roles #3768

Open
Open
@WilcoFiers

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.

Metadata

Assignees

No one assigned

    Labels

    commonsIssues in the common code (lib/commons)coreIssues in the core code (lib/core)fixBug fixesrulesIssue or false result from an axe-core rulesupport

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions