Skip to content

Commit

Permalink
fix(aria-allowed-attr): revert violation for non-global ARIA attrs on…
Browse files Browse the repository at this point in the history
… element without role (#3243)
  • Loading branch information
straker committed Oct 29, 2021
1 parent 505e6ba commit e138fd6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/checks/aria/aria-allowed-attr-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function ariaAllowedAttrEvaluate(node, options, virtualNode) {
ariaAttr.forEach(attr => {
preChecks[attr] = validateRowAttrs;
});
if (allowed) {
if (role && allowed) {
for (let i = 0; i < attrs.length; i++) {
const attrName = attrs[i];
if (validateAttr(attrName) && preChecks[attrName]?.()) {
Expand Down
12 changes: 12 additions & 0 deletions test/checks/aria/allowed-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ describe('aria-allowed-attr', function() {
assert.isNull(checkContext._data);
});

it('should return true for non-global attributes if there is no role', function() {
var vNode = queryFixture(
'<div id="target" tabindex="1" aria-selected="true" aria-owns="foo"></div>'
);

assert.isTrue(
axe.testUtils
.getCheckEvaluate('aria-allowed-attr')
.call(checkContext, null, null, vNode)
);
});

it('should not report on invalid attributes', function() {
var vNode = queryFixture(
'<div role="dialog" id="target" tabindex="1" aria-cats="true"></div>'
Expand Down
4 changes: 2 additions & 2 deletions test/integration/rules/aria-allowed-attr/failures.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<kbd aria-label="value" id="fail27"></kbd>
<abbr aria-label="value" id="fail28"></abbr>
<custom-elm aria-label="value" id="fail29"></custom-elm>
<audio
<!-- <audio
src="/test/assets/moon-speech.mp3"
controls
aria-orientation="horizontal"
id="fail30"
></audio>
></audio> -->

<div role="table">
<div role="row" aria-expanded="false" id="fail35"></div>
Expand Down
1 change: 0 additions & 1 deletion test/integration/rules/aria-allowed-attr/failures.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
["#fail27"],
["#fail28"],
["#fail29"],
["#fail30"],
["#fail35"],
["#fail36"],
["#fail37"],
Expand Down

0 comments on commit e138fd6

Please sign in to comment.