-
Notifications
You must be signed in to change notification settings - Fork 784
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
Conversation
doc/rule-descriptions.md
Outdated
| 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 | |
There was a problem hiding this comment.
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?
lib/commons/aria/get-role.js
Outdated
}); | ||
const role = validRoles[0]; | ||
|
||
// Get the impgit licit role, if permitted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: In comment - implicit
lib/commons/aria/get-role.js
Outdated
} | ||
return aria.isValidRole(role, { allowAbstract: abstracts }); | ||
}); | ||
const role = validRoles[0]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/commons/aria/get-role.js
Outdated
} | ||
return aria.isValidRole(role, { allowAbstract: abstracts }); | ||
}); | ||
const role = validRoles[0]; |
There was a problem hiding this comment.
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.
@marcysutton @JKODU Can you please review. I've got a separate fix I want to do that relies on this getting in. |
lib/commons/aria/get-role.js
Outdated
}); | ||
const explicitRole = validRoles[0]; | ||
|
||
// Get the implicit licit role, if permitted |
There was a problem hiding this comment.
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 */ | |||
|
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
test/commons/aria/get-role.js
Outdated
}); | ||
|
||
it('still returns the explicit role', function() { | ||
var node = document.createElement('li', { noImplicit: true }); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes! Indeed it is.
Updated, please look again. |
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)
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)