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(allowed-role): area without href can have a button or link role #3275

Merged
merged 2 commits into from
Nov 12, 2021
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
10 changes: 9 additions & 1 deletion lib/standards/html-elms.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,16 @@ const htmlElms = {
allowedRoles: true
},
area: {
variant: {
href: {
matches: '[href]',
allowedRoles: false
},
default: {
allowedRoles: ['button', 'link']
}
},
contentTypes: ['phrasing', 'flow'],
allowedRoles: false,
namingMethods: ['altText']
},
article: {
Expand Down
8 changes: 0 additions & 8 deletions test/commons/aria/is-aria-role-allowed-on-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,4 @@ describe('aria.isAriaRoleAllowedOnElement', function() {
var actual = axe.commons.aria.isAriaRoleAllowedOnElement(node, 'link');
assert.isTrue(actual);
});

it('returns false if elements implicit role does not match the role', function() {
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 don't think this test adds any value. It doesn't return false for just this reason, it returns false because none of the things we test for that could make it true are. So I decided to remove it rather than put in some other element.

var node = document.createElement('area');
node.setAttribute('role', 'link');
flatTreeSetup(node);
var actual = axe.commons.aria.isAriaRoleAllowedOnElement(node, 'link');
assert.isFalse(actual);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,11 @@ <h1 role="text" id="fail-text-1">ok</h1>
<button role="text" id="fail-text-2">ok</button>
<a href="#" role="text" id="fail-text-3">ok</a>
<main role="text" id="fail-text-4">ok</main>

<img usemap="#my-map">
<map name="my-map">
<area shape="circle" coords="5,5,10" role="button" id="pass-imgmap-1">
<area shape="circle" coords="5,15,10" role="link" id="pass-imgmap-2">
<area shape="circle" coords="15,5,10" href="#" role="button" id="fail-imgmap-1">
<area shape="circle" coords="15,15,10" role="checkbox" id="fail-imgmap-2">
</map>
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
["#pass-graphics-symbol"],
["#pass-img-valid-role-aria-label"],
["#pass-img-valid-role-title"],
["#pass-img-valid-role-aria-labelledby"]
["#pass-img-valid-role-aria-labelledby"],
["#pass-imgmap-1"],
["#pass-imgmap-2"]
],
"violations": [
["#fail-dd-no-role"],
Expand Down Expand Up @@ -105,7 +107,9 @@
["#fail-img-invalid-role-aria-label"],
["#fail-img-invalid-role-title"],
["#fail-img-invalid-role-aria-labelledby"],
["#fail-img-no-accessible-name-present"]
["#fail-img-no-accessible-name-present"],
["#fail-imgmap-1"],
["#fail-imgmap-2"]
],
"incomplete": [["#incomplete1"], ["#incomplete2"]]
}