Skip to content

Commit

Permalink
fix(allowed-role): area without href can have a button or link role (#…
Browse files Browse the repository at this point in the history
…3275)

* fix(allowed-role): area without href can have a button or link role

* chore: remove failing test
  • Loading branch information
WilcoFiers authored Nov 12, 2021
1 parent 1f01309 commit bf7e60a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
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() {
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"]]
}

0 comments on commit bf7e60a

Please sign in to comment.