Skip to content

Commit

Permalink
fix(aria-roles): Add WAI-ARIA 1.2 roles (#2544)
Browse files Browse the repository at this point in the history
* fix(aria-roles): Add WAI-ARIA 1.2 roles

Adds new roles from WAI-ARIA 1.2 spec

Closes issue #2107

* fix(aria-roles): Add WAI-ARIA 1.2 roles to testing

Adds new roles from WAI-ARIA 1.2 spec to test/commons/standards/get-aria-roles-by-type.js

Closes issue #2107

* fix(aria-roles): Add allowedAttrs for meter role

Adds the allowedAttrs: ['aria-valuetext'] to the meter role

Closes issue #2107

* fix(aria-roles): Add 'treegrid' to caption

Adds treegrid to caption role's requiredContext array.

Closes issue: #2107
  • Loading branch information
timmybytes authored Oct 9, 2020
1 parent 35e853d commit 635b084
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
39 changes: 39 additions & 0 deletions lib/standards/aria-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ const ariaRoles = {
type: 'landmark',
allowedAttrs: ['aria-expanded']
},
blockquote: {
type: 'structure'
},
button: {
type: 'widget',
allowedAttrs: ['aria-expanded', 'aria-pressed'],
nameFromContent: true
},
caption: {
type: 'structure',
requiredContext: ['figure', 'table', 'grid', 'treegrid']
},
cell: {
type: 'structure',
requiredContext: ['row'],
Expand All @@ -67,6 +74,9 @@ const ariaRoles = {
allowedAttrs: ['aria-checked', 'aria-readonly', 'aria-required'],
nameFromContent: true
},
code: {
type: 'structure'
},
columnheader: {
type: 'structure',
requiredContext: ['row'],
Expand Down Expand Up @@ -117,6 +127,9 @@ const ariaRoles = {
type: 'structure',
allowedAttrs: ['aria-expanded']
},
deletion: {
type: 'structure'
},
dialog: {
type: 'widget',
allowedAttrs: ['aria-expanded', 'aria-modal']
Expand All @@ -131,6 +144,9 @@ const ariaRoles = {
type: 'structure',
allowedAttrs: ['aria-expanded']
},
emphasis: {
type: 'structure'
},
feed: {
type: 'structure',
requiredOwned: ['article'],
Expand Down Expand Up @@ -191,6 +207,9 @@ const ariaRoles = {
input: {
type: 'abstract'
},
insertion: {
type: 'structure'
},
landmark: {
type: 'abstract'
},
Expand Down Expand Up @@ -284,6 +303,11 @@ const ariaRoles = {
],
nameFromContent: true
},
meter: {
type: 'structure',
allowedAttrs: ['aria-valuetext'],
requiredAttrs: ['aria-valuemax', 'aria-valuemin', 'aria-valuenow']
},
navigation: {
type: 'landmark',
allowedAttrs: ['aria-expanded']
Expand All @@ -309,6 +333,9 @@ const ariaRoles = {
],
nameFromContent: true
},
paragraph: {
type: 'structure'
},
presentation: {
type: 'structure'
},
Expand Down Expand Up @@ -488,9 +515,18 @@ const ariaRoles = {
type: 'widget',
allowedAttrs: ['aria-expanded']
},
strong: {
type: 'structure'
},
structure: {
type: 'abstract'
},
subscript: {
type: 'structure'
},
superscript: {
type: 'structure'
},
switch: {
type: 'widget',
requiredAttrs: ['aria-checked'],
Expand Down Expand Up @@ -552,6 +588,9 @@ const ariaRoles = {
'aria-required'
]
},
time: {
type: 'structure'
},
timer: {
type: 'widget',
allowedAttrs: ['aria-expanded']
Expand Down
12 changes: 12 additions & 0 deletions test/commons/standards/get-aria-roles-by-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,40 @@ describe('standards.getAriaRolesByType', function() {
var structureRoles = getAriaRolesByType('structure');
assert.deepEqual(structureRoles, [
'article',
'blockquote',
'caption',
'cell',
'code',
'columnheader',
'definition',
'deletion',
'directory',
'document',
'emphasis',
'feed',
'figure',
'group',
'heading',
'img',
'insertion',
'list',
'listitem',
'math',
'meter',
'none',
'note',
'paragraph',
'presentation',
'row',
'rowgroup',
'rowheader',
'separator',
'strong',
'subscript',
'superscript',
'table',
'term',
'time',
'toolbar',
'tooltip'
]);
Expand Down

0 comments on commit 635b084

Please sign in to comment.