Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make global ARIA attributes configurable in aria-allowed-attr #2108

Closed
WilcoFiers opened this issue Mar 23, 2020 · 3 comments · Fixed by #2395
Closed

Make global ARIA attributes configurable in aria-allowed-attr #2108

WilcoFiers opened this issue Mar 23, 2020 · 3 comments · Fixed by #2395
Assignees
Labels
configuration rules / checks customisation docs Documentation changes feat New feature or enhancement rules Issue or false result from an axe-core rule
Milestone

Comments

@WilcoFiers
Copy link
Contributor

To make axe-core more flexible and allow it to support different environments it would be helpful to add more configuration options. One such option is to be able to set which global attributes are available in aria-allowed-attr, see #2078 for details.

@WilcoFiers WilcoFiers added feat New feature or enhancement rules Issue or false result from an axe-core rule labels Mar 23, 2020
@WilcoFiers WilcoFiers added this to the Axe-core 4.0 milestone Mar 23, 2020
@WilcoFiers WilcoFiers added the configuration rules / checks customisation label Jun 1, 2020
@straker straker self-assigned this Jul 17, 2020
@straker straker reopened this Jul 20, 2020
@straker
Copy link
Contributor

straker commented Jul 20, 2020

QA: to test this you can take a rule such as aria-allowed-attrs and test any role in the new standards object that has an allowedAttrs property. First test that you can't add an aria-attribute that is not one 1) global 2) part of the reuqiredAttrs and 3) part of the allowedAttrs, then configure the role to allow the aria-attribute using axe.configure.

For example, the checkbox role allows attributes aria-checked, aria-readonly, and aria-required. To test, you can add aria-expanded to an element that has role=checkbox and see that it should fail aria-allowed-attrs rule. Then configure the standards object to allow it and test it again, and it should pass.

<div role="checkbox" aria-expanded="true" aria-checked="true"></div>

<script>
axe.configure({
  standards: {
    // the standards object to configure https://github.com/dequelabs/axe-core/blob/develop/lib/standards
    ariaRoles: {
      // the role to configure
      checkbox: {
        // the property to configure. with arrays you'll need to copy what's in the standards
        //  object and add the new values, otherwise the previous values will be removed
        // (meaning `aria-checked`, etc. would no longer be allowed)
        allowedAttrs: ['aria-checked', 'aria-readonly', 'aria-required', 'aria-expanded']
      }
    }
  }
});
</script>

await axe.run();  // so not show violation for `aria-allowed-attrs` for `aria-expanded` on the checkbox role

You should also test other rules in a similar manner such as aria-valid-attr (by adding a new attribute to the ariaAttrs object), aria-valid-attr-value, aria-roles (by adding a new role to the ariaRoles object), aria-required-parent (requiredContext property), and aria-required-children (requiredOwned property).

@padmavemulapati
Copy link

padmavemulapati commented Jul 21, 2020

Verified as per QA notes using latest axe-core(3.5.5 pulled code)
Step1: for the test file <div role="checkbox" aria-expanded="true" aria-checked="true">Hello</div>
Simply running axe - would result - failure for aria-allowed-attr (attached the Screenshot)
image

Step2: configured with axe.configure({ standards: { ariaRoles: { checkbox: { allowedAttrs: ['aria-checked', 'aria-readonly', 'aria-required', 'aria-expanded'] } } } });
and did - axe.run(); - resulting - pass for aria-allowed-attr (attached the screenshot)
image

@jeankaplansky
Copy link
Contributor

Included in internal release notes 7/27/2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration rules / checks customisation docs Documentation changes feat New feature or enhancement rules Issue or false result from an axe-core rule
Projects
None yet
4 participants