Skip to content

Commit

Permalink
fix(aria-allowed-children,aria-allowed-parent): allow group role in l…
Browse files Browse the repository at this point in the history
…istbox (#3195)

* fix(aria-allowed-children,aria-allowed-parent): allow group role in listbox

* fix tests
  • Loading branch information
straker committed Oct 18, 2021
1 parent aa9c145 commit d742b29
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/standards/aria-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const ariaRoles = {
},
listbox: {
type: 'composite',
requiredOwned: ['option'],
requiredOwned: ['group', 'option'],
allowedAttrs: [
'aria-multiselectable',
'aria-readonly',
Expand Down Expand Up @@ -408,7 +408,7 @@ const ariaRoles = {
},
option: {
type: 'widget',
requiredContext: ['listbox'],
requiredContext: ['group', 'listbox'],
// Note: since the option role has an implicit
// aria-selected value it is not required to be added by
// the user
Expand Down
2 changes: 1 addition & 1 deletion test/checks/aria/required-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ describe('aria-required-children', function() {

it('should fail when role does not allow group', function() {
var params = checkSetup(
'<div role="listbox" id="target"><ul role="group"><li role="option">Option</li></ul></div>'
'<div role="table" id="target"><ul role="group"><li role="row">Option</li></ul></div>'
);
assert.isFalse(
axe.testUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@
<li role="menuitem" id="ignore14">>Trash</li>
</ul>
</div>

<div role="suggestion" id="pass8">
<span role="deletion">option</span>
<span role="insertion">option</span>
</div>

<div role="suggestion" id="fail8"></div>

<div role="listbox" id="pass9">
<div role="group">
<div role="option">option</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
["#pass4"],
["#pass5"],
["#pass6"],
["#pass7"]
["#pass7"],
["#pass8"],
["#pass9"]
],
"incomplete": [
["#incomplete1"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@
</div>
</div>
</div>

<div role="listbox">
<div role="group">
<div role="option" id="pass13">option</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
["#pass9"],
["#pass10"],
["#pass11"],
["#pass12"]
["#pass12"],
["#pass13"]
]
}

0 comments on commit d742b29

Please sign in to comment.