Skip to content

Commit

Permalink
feat(aria-required-children): add aria-busy check (#3569)
Browse files Browse the repository at this point in the history
Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
  • Loading branch information
pschwendy and WilcoFiers authored Aug 5, 2022
1 parent 9b932fb commit 3618f50
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 4 deletions.
9 changes: 9 additions & 0 deletions lib/checks/aria/aria-busy-evaluate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Checks if element has aria-busy tag set to "true"
*
* @memberof checks
* @return {Boolean} True if node has "aria-busy" attribute. False otherwise
*/
export default function ariaBusyEvaluate(node, options, virtualNode) {
return virtualNode.attr('aria-busy') === 'true';
}
11 changes: 11 additions & 0 deletions lib/checks/aria/aria-busy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "aria-busy",
"evaluate": "aria-busy-evaluate",
"metadata": {
"impact": "serious",
"messages": {
"pass": "Element has an aria-busy attribute",
"fail": "Element has no aria-busy=\"true\" attribute"
}
}
}
2 changes: 1 addition & 1 deletion lib/rules/aria-required-children.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"help": "Certain ARIA roles must contain particular children"
},
"all": [],
"any": ["aria-required-children"],
"any": ["aria-required-children", "aria-busy"],
"none": []
}
30 changes: 30 additions & 0 deletions test/checks/aria/aria-busy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
describe('aria-busy', function() {
'use strict';

var checkContext = axe.testUtils.MockCheckContext();
var checkSetup = axe.testUtils.checkSetup;
var checkEvaluate = axe.testUtils.getCheckEvaluate('aria-busy');

afterEach(function() {
checkContext.reset();
});

it('should return false if no aria-busy tag on element', function() {
var params = checkSetup('<div id="target" role="list"></div>');
assert.isFalse(checkEvaluate.apply(checkContext, params));
});

it('should return false if aria-busy is set to false', function() {
var params = checkSetup(
'<div id="target" role="list" aria-busy="false"></div>'
);
assert.isFalse(checkEvaluate.apply(checkContext, params));
});

it('should return true if aria-busy is set to true', function() {
var params = checkSetup(
'<div id="target" role="list" aria-busy="true"></div>'
);
assert.isTrue(checkEvaluate.apply(checkContext, params));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,19 @@
</div>
</div>

<div role="list" id="pass10" aria-busy="true"></div>
<div role="suggestion" id="pass11" aria-busy="true"></div>
<div role="menu" id="pass12" aria-busy="true"></div>
<div role="listbox" id="pass13" aria-busy="true"></div>

<div role="suggestion" id="fail9">
<div aria-busy="true"></div>
</div>
<div role="suggestion" id="fail10" aria-busy="false"></div>

<div role="list" id="incomplete10">
<div aria-busy="true"></div>
</div>

<div role="doc-bibliography" id="inapplicable1"></div>
<div role="doc-endnotes" id="inapplicable2"></div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
["#fail5"],
["#fail6"],
["#fail7"],
["#fail8"]
["#fail8"],
["#fail9"],
["#fail10"]
],
"passes": [
["#pass1"],
Expand All @@ -20,7 +22,11 @@
["#pass6"],
["#pass7"],
["#pass8"],
["#pass9"]
["#pass9"],
["#pass10"],
["#pass11"],
["#pass12"],
["#pass13"]
],
"incomplete": [
["#incomplete1"],
Expand All @@ -31,6 +37,7 @@
["#incomplete6"],
["#incomplete7"],
["#incomplete8"],
["#incomplete9"]
["#incomplete9"],
["#incomplete10"]
]
}

0 comments on commit 3618f50

Please sign in to comment.