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

feat: flag unsupported roles #1064

Merged
merged 3 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this template string for? This could just be out.push(key, ...).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Agree

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, that's a question for @JKODU

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@stephenmathieson stephenmathieson Aug 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but why are we wrapping a variable in backticks here? Consider the following:

var a = `${key}`
var b = 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.keys creates an array of just the roles, I needed the whole object.

]),
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hyphenated? unsupported-role is more ascetically pleasing and easier to read (IMO).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following abstractrole and invalidrole, but I could change it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, makes sense. I'm +1 for consistency, so no need to change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I'm working on attributes, I wish we would have added a hyphen.... the role thing is inconsistent with the rest of axe-core checks. oh well...

"evaluate": "unsupportedrole.js",
"metadata": {
"impact": "critical",
"messages": {
"pass": "ARIA role is supported",
"fail": "The role used is not widely supported in assistive technologies"
Copy link
Contributor

@WilcoFiers WilcoFiers Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say "in screen readers", or "in screen readers and other assistive technologies"? Also, should we include the actual role?

}
}
}
Loading