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: Add aria.getRole method #1017

Merged
merged 10 commits into from
Aug 7, 2018
Merged

feat: Add aria.getRole method #1017

merged 10 commits into from
Aug 7, 2018

Conversation

WilcoFiers
Copy link
Contributor

@WilcoFiers WilcoFiers commented Jul 20, 2018

I've got some uses lined up for this. This function is over due :), and is going to help us deal with multiple roles properly at some point in the future.

This PR is awaiting merger of #1015.

Closes issue: none

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)

| 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 remark, shouldn't these documentation updates be a part of another build where these changes were made to the respective rules? Worth folding into a new PR?

});
const role = validRoles[0];

// Get the impgit licit role, if permitted
Copy link
Contributor

Choose a reason for hiding this comment

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

Edit: In comment - implicit

}
return aria.isValidRole(role, { allowAbstract: abstracts });
});
const role = validRoles[0];
Copy link
Contributor

@jeeyyy jeeyyy Jul 28, 2018

Choose a reason for hiding this comment

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

need a length check on validRoles here, there is a chance that this can be an empty array, if role is not defined in a given node.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't matter. In that case role undefined, which is what it should be.

@jeeyyy
Copy link
Contributor

jeeyyy commented Jul 28, 2018

@WilcoFiers
I also think this could have been an enhancement to existing getRoleSegments method with an optional argument to return just the first valid role.

Copy link
Contributor Author

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

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

@JKODU getRoleSegments doesn't exist yet. It is new in #945. Given Romain's comment about support for type, I don't think we need it. Most of what it does is covered by axe.utils.tokenList.

}
return aria.isValidRole(role, { allowAbstract: abstracts });
});
const role = validRoles[0];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't matter. In that case role undefined, which is what it should be.

@WilcoFiers WilcoFiers changed the title (WIP) feat: Add aria.getRole method feat: Add aria.getRole method Aug 5, 2018
@WilcoFiers
Copy link
Contributor Author

@marcysutton @JKODU Can you please review. I've got a separate fix I want to do that relies on this getting in.

});
const explicitRole = validRoles[0];

// Get the implicit licit role, if permitted
Copy link
Contributor

Choose a reason for hiding this comment

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

editorial: implicit licit...

@@ -0,0 +1,25 @@
/* global aria, axe */

Copy link
Contributor

Choose a reason for hiding this comment

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

Add jsdoc comments please, with @return decorating what is expected.

}
return aria.isValidRole(role, { allowAbstract: abstracts });
});
const explicitRole = validRoles[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

So if validRoles is an empty array, explicitRole will be undefined.
Line 24 below will do a undefined || null and null will be returned. Is that what is expected? Asking, as in some places we expect an undefined, so long as it is document and we agree on the return, happy with this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, tests below, tell me null is expected as return. So all good.

jeeyyy
jeeyyy previously approved these changes Aug 5, 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.

LGTM, asides jsdoc comments.

});

it('still returns the explicit role', function() {
var node = document.createElement('li', { noImplicit: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this noImplicit option supposed to go in the call to aria.getRole instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yikes! Indeed it is.

@WilcoFiers
Copy link
Contributor Author

Updated, please look again.

@WilcoFiers WilcoFiers merged commit f64ff10 into develop Aug 7, 2018
@WilcoFiers WilcoFiers deleted the aria-getrole branch August 7, 2018 22:41
@WilcoFiers WilcoFiers mentioned this pull request Aug 27, 2018
8 tasks
WilcoFiers added a commit that referenced this pull request Aug 27, 2018
Review 10% (50 max) of the following (Product manager only):

- [x] feat: Update FR (french) translation file for 3.1 release (#1089) (4a5cad0)
- [x] chore: Fix example dependency mistake (#1094) (6af5733)
- [x] fix: Do not require media captions / descriptions (#1075) (289f623)
- [x] feat(aria-role): Remove non-existing "text" role (#1069) (67ec1f5)
- [x] Merge pull request #1017 from dequelabs/aria-getrole (f64ff10)
- [x] chore: remove `.jshintrc` files (#1028) (03b3327)
- [x] chore: ability to add external libs (axios) (0957dab)
- [x] Merge pull request #985 from dequelabs/git-update (54b0b60)
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.

4 participants