axe-core icon indicating copy to clipboard operation
axe-core copied to clipboard

Support fallback roles

Open WilcoFiers opened this issue 3 years ago • 2 comments

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.

WilcoFiers avatar Nov 02 '22 17:11 WilcoFiers