Skip to content

Commit

Permalink
feat: Flag unsupported roles (#1064)
Browse files Browse the repository at this point in the history
Adds `unsupported` property to the `lookupTable.role` dictionary. New option for `aria.isValidRole` to `flagUnsupported` roles. Defaults to `false` since this commons function is reused for multiple checks.

Part one of #918.

TODO: 
- Add `unsupported` to lookupTable.attributes
- Figure out what to do with globalAttributes, which are currently a flat array
- Add `axe.commons.support` API and enable control of it through `axe.configure`

## Reviewer checks

**Required fields, to be filled out by PR reviewer(s)**
- [x] Follows the commit message policy, appropriate for next version
- [x] Has documentation updated, a DU ticket, or requires no documentation change
- [x] Includes new tests, or was unnecessary
- [x] Code is reviewed for security by: @WilcoFiers
  • Loading branch information
marcysutton authored and WilcoFiers committed Aug 15, 2018
1 parent d262a35 commit 5515ee6
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 132 deletions.
25 changes: 17 additions & 8 deletions build/tasks/aria-supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,30 @@ module.exports = function(grunt) {
.reduce((out, [key] = item) => {
switch (listType) {
case 'supported':
if (subject.includes(key)) {
if (
subject.hasOwnProperty(key) &&
subject[key].unsupported === false
) {
out.push([`${key}`, 'Yes']);
}
break;
case 'unsupported':
if (!subject.includes(key)) {
if (
(subject[key] && subject[key].unsupported === true) ||
!subject.hasOwnProperty(key)
) {
out.push([`${key}`, 'No']);
}
break;
case 'all':
default:
out.push([`${key}`, subject.includes(key) ? 'Yes' : 'No']);
out.push([
`${key}`,
subject.hasOwnProperty(key) &&
subject[key].unsupported === false
? 'Yes'
: 'No'
]);
break;
}
return out;
Expand All @@ -75,14 +87,11 @@ module.exports = function(grunt) {
} in axe-core.`,
mdTable([
['aria-role', 'axe-core support'],
...getDiff(roles, Object.keys(axe.commons.aria.lookupTable.role))
...getDiff(roles, axe.commons.aria.lookupTable.role)
]),
mdTable([
['aria-attribute', 'axe-core support'],
...getDiff(
aQaria,
Object.keys(axe.commons.aria.lookupTable.attributes)
)
...getDiff(aQaria, axe.commons.aria.lookupTable.attributes)
])
);
grunt.file.write(destFile, content);
Expand Down
3 changes: 3 additions & 0 deletions lib/checks/aria/unsupportedrole.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return !axe.commons.aria.isValidRole(node.getAttribute('role'), {
flagUnsupported: true
});
11 changes: 11 additions & 0 deletions lib/checks/aria/unsupportedrole.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "unsupportedrole",
"evaluate": "unsupportedrole.js",
"metadata": {
"impact": "critical",
"messages": {
"pass": "ARIA role is supported",
"fail": "The role used is not widely supported in assistive technologies"
}
}
}
Loading

0 comments on commit 5515ee6

Please sign in to comment.