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

fix(aria-allowed-attr): pass aria-expanded on checkbox & switch #4110

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions lib/standards/aria-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
const ariaRoles = {
alert: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
alertdialog: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded', 'aria-modal'],
superclassRole: ['alert', 'dialog'],
accessibleNameRequired: true
Expand All @@ -38,11 +40,13 @@ const ariaRoles = {
},
article: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-posinset', 'aria-setsize', 'aria-expanded'],
superclassRole: ['document']
},
banner: {
type: 'landmark',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['landmark']
},
Expand All @@ -67,6 +71,7 @@ const ariaRoles = {
cell: {
type: 'structure',
requiredContext: ['row'],
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-colindex',
'aria-colspan',
Expand All @@ -82,7 +87,7 @@ const ariaRoles = {
// Note: aria-required is not in the 1.1 spec but is
// consistently supported in ATs and was added in 1.2
requiredAttrs: ['aria-checked'],
allowedAttrs: ['aria-readonly', 'aria-required'],
allowedAttrs: ['aria-readonly', 'aria-expanded', 'aria-required'],
superclassRole: ['input'],
accessibleNameRequired: true,
nameFromContent: true,
Expand All @@ -96,6 +101,7 @@ const ariaRoles = {
columnheader: {
type: 'structure',
requiredContext: ['row'],
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-sort',
'aria-colindex',
Expand Down Expand Up @@ -132,6 +138,7 @@ const ariaRoles = {
},
complementary: {
type: 'landmark',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['landmark']
},
Expand All @@ -141,6 +148,7 @@ const ariaRoles = {
},
contentinfo: {
type: 'landmark',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['landmark']
},
Expand All @@ -151,6 +159,7 @@ const ariaRoles = {
},
definition: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
Expand All @@ -161,20 +170,23 @@ const ariaRoles = {
},
dialog: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded', 'aria-modal'],
superclassRole: ['window'],
accessibleNameRequired: true
},
directory: {
type: 'structure',
deprecated: true,
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['list'],
// Note: spec difference
nameFromContent: true
},
document: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['structure']
},
Expand All @@ -186,24 +198,28 @@ const ariaRoles = {
feed: {
type: 'structure',
requiredOwned: ['article'],
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['list']
},
figure: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section'],
// Note: spec difference
nameFromContent: true
},
form: {
type: 'landmark',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['landmark']
},
grid: {
type: 'composite',
requiredOwned: ['rowgroup', 'row'],
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-level',
'aria-multiselectable',
Expand Down Expand Up @@ -235,12 +251,14 @@ const ariaRoles = {
},
group: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-activedescendant', 'aria-expanded'],
superclassRole: ['section']
},
heading: {
type: 'structure',
requiredAttrs: ['aria-level'],
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['sectionhead'],
// Note: spec difference
Expand All @@ -249,6 +267,7 @@ const ariaRoles = {
},
img: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section'],
accessibleNameRequired: true,
Expand Down Expand Up @@ -277,6 +296,7 @@ const ariaRoles = {
list: {
type: 'structure',
requiredOwned: ['listitem'],
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
Expand Down Expand Up @@ -309,21 +329,25 @@ const ariaRoles = {
},
log: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
main: {
type: 'landmark',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['landmark']
},
marquee: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
math: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section'],
childrenPresentational: true
Expand All @@ -339,6 +363,7 @@ const ariaRoles = {
'menu',
'separator'
],
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-activedescendant',
'aria-expanded',
Expand All @@ -357,6 +382,7 @@ const ariaRoles = {
'menu',
'separator'
],
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-activedescendant',
'aria-expanded',
Expand Down Expand Up @@ -419,6 +445,7 @@ const ariaRoles = {
},
navigation: {
type: 'landmark',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['landmark']
},
Expand All @@ -429,6 +456,7 @@ const ariaRoles = {
},
note: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
Expand Down Expand Up @@ -461,6 +489,7 @@ const ariaRoles = {
},
progressbar: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-expanded',
'aria-valuemax',
Expand All @@ -486,6 +515,7 @@ const ariaRoles = {
radiogroup: {
type: 'composite',
// Note: spec difference (no required owned)
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-readonly',
'aria-required',
Expand All @@ -503,6 +533,7 @@ const ariaRoles = {
},
region: {
type: 'landmark',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['landmark'],
// Note: spec difference
Expand Down Expand Up @@ -539,6 +570,7 @@ const ariaRoles = {
rowheader: {
type: 'structure',
requiredContext: ['row'],
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-sort',
'aria-colindex',
Expand Down Expand Up @@ -577,6 +609,7 @@ const ariaRoles = {
},
search: {
type: 'landmark',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['landmark']
},
Expand Down Expand Up @@ -664,6 +697,7 @@ const ariaRoles = {
},
status: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
Expand All @@ -689,7 +723,7 @@ const ariaRoles = {
switch: {
type: 'widget',
requiredAttrs: ['aria-checked'],
allowedAttrs: ['aria-readonly', 'aria-required'],
allowedAttrs: ['aria-expanded', 'aria-readonly', 'aria-required'],
superclassRole: ['checkbox'],
accessibleNameRequired: true,
nameFromContent: true,
Expand Down Expand Up @@ -717,6 +751,7 @@ const ariaRoles = {
table: {
type: 'structure',
requiredOwned: ['rowgroup', 'row'],
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-colcount', 'aria-rowcount', 'aria-expanded'],
// NOTE: although the spec says this is not named from contents,
// the accessible text acceptance tests (#139 and #140) require
Expand All @@ -743,13 +778,15 @@ const ariaRoles = {
},
tabpanel: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section'],
// Note: spec difference
accessibleNameRequired: false
},
term: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section'],
// Note: spec difference
Expand All @@ -775,15 +812,19 @@ const ariaRoles = {
},
time: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
WilcoFiers marked this conversation as resolved.
Show resolved Hide resolved
superclassRole: ['section']
},
timer: {
type: 'widget',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['status']
},
toolbar: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-orientation',
'aria-activedescendant',
Expand All @@ -794,13 +835,15 @@ const ariaRoles = {
},
tooltip: {
type: 'structure',
// Aria-expanded removed as of 1.3
allowedAttrs: ['aria-expanded'],
superclassRole: ['section'],
nameFromContent: true
},
tree: {
type: 'composite',
requiredOwned: ['group', 'treeitem'],
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-multiselectable',
'aria-required',
Expand All @@ -815,6 +858,7 @@ const ariaRoles = {
treegrid: {
type: 'composite',
requiredOwned: ['rowgroup', 'row'],
// Aria-expanded removed as of 1.3
allowedAttrs: [
'aria-activedescendant',
'aria-colcount',
Expand Down
4 changes: 3 additions & 1 deletion test/integration/rules/aria-allowed-attr/passes.html
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,7 @@
<div
role="switch"
id="pass62"
aria-expanded="value"
aria-checked="value"
aria-atomic="value"
aria-braillelabel="value"
Expand Down Expand Up @@ -2092,8 +2093,9 @@
<button id="pass73" aria-roledescription="attachment button"></button>
<input
type="checkbox"
aria-roledescription="cuisine type checkbox"
id="pass74"
aria-roledescription="cuisine type checkbox"
aria-expanded="false"
/>

<span role="radio" id="pass75" aria-checked="false">I am RED!</span>
Expand Down