Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(required-attr): require aria-checked for checkbox-like and radio-like roles #3785

Merged
merged 2 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 8 additions & 27 deletions lib/standards/aria-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,10 @@ const ariaRoles = {
},
checkbox: {
type: 'widget',
// Note: since the checkbox role has an implicit
// aria-checked value it is not required to be added by
// the user
//
// Note: aria-required is not in the 1.1 spec but is
// consistently supported in ATs and was added in 1.2
allowedAttrs: ['aria-checked', 'aria-readonly', 'aria-required'],
requiredAttrs: ['aria-checked'],
allowedAttrs: ['aria-readonly', 'aria-required'],
superclassRole: ['input'],
accessibleNameRequired: true,
nameFromContent: true,
Expand Down Expand Up @@ -370,12 +367,8 @@ const ariaRoles = {
menuitemcheckbox: {
type: 'widget',
requiredContext: ['menu', 'menubar', 'group'],
allowedAttrs: [
'aria-checked',
'aria-posinset',
'aria-readonly',
'aria-setsize'
],
requiredAttrs: ['aria-checked'],
allowedAttrs: ['aria-posinset', 'aria-readonly', 'aria-setsize'],
superclassRole: ['checkbox', 'menuitem'],
accessibleNameRequired: true,
nameFromContent: true,
Expand All @@ -384,12 +377,8 @@ const ariaRoles = {
menuitemradio: {
type: 'widget',
requiredContext: ['menu', 'menubar', 'group'],
allowedAttrs: [
'aria-checked',
'aria-posinset',
'aria-readonly',
'aria-setsize'
],
requiredAttrs: ['aria-checked'],
allowedAttrs: ['aria-posinset', 'aria-readonly', 'aria-setsize'],
superclassRole: ['menuitemcheckbox', 'radio'],
accessibleNameRequired: true,
nameFromContent: true,
Expand Down Expand Up @@ -465,18 +454,10 @@ const ariaRoles = {
},
radio: {
type: 'widget',
// Note: since the radio role has an implicit
// aria-check value it is not required to be added by
// the user
//
// Note: aria-required is not in the 1.1 or 1.2 specs but is
// consistently supported in ATs on the individual radio element
allowedAttrs: [
'aria-checked',
'aria-posinset',
'aria-setsize',
'aria-required'
],
requiredAttrs: ['aria-checked'],
allowedAttrs: ['aria-posinset', 'aria-setsize', 'aria-required'],
superclassRole: ['input'],
accessibleNameRequired: true,
nameFromContent: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
>
ok
</div>
<span role="radio" id="pass6">I am BLUE!</span>
<span role="radio" id="pass7" aria-checked="false">I am RED!</span>
<span role="radio" id="pass6" aria-checked="false">I am RED!</span>
<span role="radio" id="pass7" aria-checked="true">I am GREEN!</span>
<span role="radio" id="pass8" aria-checked="true">I am GREEN!</span>
<input type="number" role="spinbutton" id="pass9" value="10" />
<input type="number" role="spinbutton" id="pass10" />
Expand All @@ -55,3 +55,4 @@
<div role="slider" id="violation2">fail</div>
<div role="heading" id="violation3">fail</div>
<div role="combobox" id="violation4">fail</div>
<span role="radio" id="violation5">I am BLUE!</span>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
["#violation1"],
["#violation2"],
["#violation3"],
["#violation4"]
["#violation4"],
["#violation5"]
],
"passes": [
["#pass1"],
Expand Down