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

fix: Ignore abstracts in determining element roles #1015

Merged
merged 5 commits into from
Aug 2, 2018

Conversation

WilcoFiers
Copy link
Contributor

@WilcoFiers WilcoFiers commented Jul 18, 2018

Added allowAbstract to aria.isValidRole and put it to use in a few places. Couple of things to note:

  • There are other places where aria.isValidRole is used, I looked at those and I didn't think they needed this. But you might want to check it out for yourself.
  • This PR fixes a bug that was introduced in a PR that landed earlier today. The PR caused invalid roles to fail the list rules, rather than having it ignore them. There's no ticket for it.

Closes #1014

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Has documentation updated, a DU ticket, or requires no documentation change
  • Includes new tests, or was unnecessary
  • Code is reviewed for security by: Jey (@JKODU)

@@ -1,18 +1,21 @@
const parent = axe.commons.dom.getComposedParent(node);
if (!parent) {
return false;
// Can only happen with detached DOM nodes and roots:
Copy link
Contributor

Choose a reason for hiding this comment

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

should we do similar check for dlitem ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could have. If I wasn't already in the process of changing these functions I would.

(ALLOWED_TAGS.includes(parentTagName) && (!parentRole || isListRole)) ||
isListRole
);
return ['UL', 'OL'].includes(parentTagName);
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
Contributor Author

Choose a reason for hiding this comment

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

readable code FTW

}
console.log(explicitRoles);
Copy link
Contributor

Choose a reason for hiding this comment

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

intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorted

jeeyyy
jeeyyy previously approved these changes Jul 18, 2018
Copy link
Contributor

@jeeyyy jeeyyy left a comment

Choose a reason for hiding this comment

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

Some minor comments left.

return true;
}

if (parentRole && axe.commons.aria.isValidRole(parentRole)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this check for ARIA roles that aren't list to return false, like the code did before?

if (parentRole && !axe.commons.aria.isValidRole(parentRole)) {

Copy link
Contributor Author

@WilcoFiers WilcoFiers Jul 21, 2018

Choose a reason for hiding this comment

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

This fixes the bug I mentioned in the description:

This PR fixes a bug that was introduced in a PR that landed earlier today. The PR caused invalid roles to fail the list rules, rather than having it ignore them. There's no ticket for it.

'use strict';
if (aria.lookupTable.role[role]) {
return true;
aria.isValidRole = function(role, { allowAbstract } = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The description of this issue says disallowAbstract, while this says allowAbstract. Shouldn't they be the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gd point, forgot to update the description. I flipped it around after talking to Dylan about what we can and can't do with commons in minor releases. The more sensible default is to not consider abstract roles valid, so the default allowAbstract: false is used.

jeeyyy
jeeyyy previously approved these changes Jul 28, 2018
| landmark-no-duplicate-banner | Ensures the document has no more than one banner landmark | Moderate | cat.semantics, best-practice | true |
| landmark-no-duplicate-contentinfo | Ensures the document has no more than one contentinfo landmark | Moderate | cat.semantics, best-practice | true |
| landmark-one-main | Ensures a navigation point to the primary content of the page. If the page contains iframes, each iframe should contain either no main landmarks or just one | Moderate | cat.semantics, best-practice | true |
| landmark-banner-is-top-level | Ensures the banner landmark is at top level | Moderate | cat.semantics, best-practice | true |
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: move these documentation updates to separate PR

@@ -1 +1,3 @@
return !axe.commons.aria.isValidRole(node.getAttribute('role'));
return !axe.commons.aria.isValidRole(node.getAttribute('role'), {
allowAbstract: true
Copy link
Contributor

@marcysutton marcysutton Aug 1, 2018

Choose a reason for hiding this comment

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

The word allow is throwing me off here, like abstract roles are being "permitted" rather than "included for evaluation". Maybe that's just me though?

Edit: I suppose that's because we are in fact allowing abstracts, as they are ignored by the accessibility API. Carry on.

@WilcoFiers WilcoFiers merged commit a60e60e into develop Aug 2, 2018
@WilcoFiers WilcoFiers deleted the isValidRole-abstracts branch August 2, 2018 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aria.isValidRole should take abstract roles into consideration
3 participants