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 authored Oct 29, 2021
1 parent f001af6 commit 112b960
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 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
14 changes: 13 additions & 1 deletion test/checks/aria/allowed-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('aria-allowed-attr', function() {
assert.isNull(checkContext._data);
});

it('should return false for non-global attributes if there is no role', function() {
it.skip('should return false 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>'
);
Expand All @@ -72,6 +72,18 @@ describe('aria-allowed-attr', function() {
assert.deepEqual(checkContext._data, ['aria-selected="true"']);
});

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="mark" aria-label="value" id="fail31">fail</div>
<div role="mark" aria-labelledby="value" id="fail32">fail</div>
<div role="suggestion" aria-label="value" id="fail33">fail</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"],
["#fail31"],
["#fail32"],
["#fail33"],
Expand Down
2 changes: 1 addition & 1 deletion test/integration/virtual-rules/aria-allowed-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('aria-allowed-attr virtual-rule', function() {
assert.lengthOf(results.incomplete, 0);
});

it('should fail for non-global attributes and element with no role', function() {
it.skip('should fail for non-global attributes and element with no role', function() {
var results = axe.runVirtualRule('aria-allowed-attr', {
nodeName: 'div',
attributes: {
Expand Down

0 comments on commit 112b960

Please sign in to comment.