Skip to content

Commit f7f6120

Browse files
authored
Audited and updated roles source of truth to HTML Accessibility API Mapping 1.0 (#447)
1 parent c9dd9dd commit f7f6120

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1922
-5217
lines changed

__tests__/src/ariaPropsMaps-test.js

+117-549
Large diffs are not rendered by default.

__tests__/src/domMap-test.js

+195-1,359
Large diffs are not rendered by default.

__tests__/src/elementRoleMap-test.js

+183-1,032
Large diffs are not rendered by default.

__tests__/src/roleElementMap-test.js

+131-571
Large diffs are not rendered by default.

__tests__/src/rolesMap-test.js

+203-1,129
Large diffs are not rendered by default.

flow/aria.js

+58-26
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type ARIADocumentStructureRole =
7070
| 'insertion'
7171
| 'list'
7272
| 'listitem'
73+
| 'mark'
7374
| 'math'
7475
| 'meter'
7576
| 'none'
@@ -166,36 +167,48 @@ type ARIARole =
166167
| ARIALandmarkRole
167168
| ARIALiveRegionRole
168169
| ARIAWindowRole
169-
| ARIAUncategorizedRole;
170+
| ARIAUncategorizedRole
171+
| ARIADPubRole
172+
| ARIAGraphicsRole;
170173

171174
type ARIARoleDefinitionKey =
172175
ARIAAbstractRole
173176
| ARIARole
174177
| ARIADPubRole
175178
| ARIAGraphicsRole;
176179

177-
type ARIARoleDefinition = {
180+
type ARIANameFromSources =
181+
'author'
182+
| 'contents'
183+
| 'prohibited';
184+
185+
type ARIARoleDefinition = {|
178186
/* Abstract roles may not be used in HTML. */
179187
abstract: boolean,
188+
accessibleNameRequired: boolean,
180189
/* The concepts in related domains that inform behavior mappings. */
181190
baseConcepts: Array<ARIARoleRelation>,
182191
/* Child presentational roles strip child nodes of roles and flatten the
183192
* content to text. */
184193
childrenPresentational: boolean,
194+
nameFrom?: Array<ARIANameFromSources>,
185195
/* aria-* properties and states disallowed on this role. */
186196
prohibitedProps: $Keys<ARIAPropertyMap>[],
187197
/* aria-* properties and states allowed on this role. */
188198
props: ARIAPropertyMap,
189199
/* The concepts in related domains that inform behavior mappings. */
190200
relatedConcepts: Array<ARIARoleRelation>,
201+
requireContextRole?: Array<ARIARole>,
202+
requiredContextRole?: Array<ARIARole>,
203+
requiredOwnedElements?: Array<Array<string>>,
191204
/* aria-* properties and states required on this role. */
192205
requiredProps: ARIAPropertyMap,
193206
/* An array or super class "stacks." Each stack contains a LIFO list of
194207
* strings correspond to a super class in the inheritance chain of this
195208
* role. Roles may have more than one inheritance chain, which is why
196209
* this property is an array of arrays and not a single array. */
197210
superClass: Array<Array<ARIAAbstractRole | ARIARole | ARIADPubRole>>,
198-
};
211+
|};
199212

200213
type RoleDefinitionTuple = [ARIARoleDefinitionKey, ARIARoleDefinition];
201214
type RoleDefinitions = Array<RoleDefinitionTuple>;
@@ -215,12 +228,15 @@ type ARIAProperty =
215228
'aria-activedescendant'
216229
| 'aria-atomic'
217230
| 'aria-autocomplete'
231+
| 'aria-braillelabel'
232+
| 'aria-brailleroledescription'
218233
| 'aria-colcount'
219234
| 'aria-colindex'
220235
| 'aria-colspan'
221236
| 'aria-controls'
222237
| 'aria-current'
223238
| 'aria-describedby'
239+
| 'aria-description'
224240
| 'aria-details'
225241
| 'aria-dropeffect'
226242
| 'aria-errormessage'
@@ -255,29 +271,30 @@ type ARIAProperty =
255271

256272
// {| [AriaProperty]?: mixed |}
257273
type ARIAPropertyMap = {|
258-
'aria-busy'?: mixed,
259-
'aria-checked'?: mixed,
260-
'aria-disabled'?: mixed,
261-
'aria-expanded'?: mixed,
262-
'aria-grabbed'?: mixed,
263-
'aria-hidden'?: mixed,
264-
'aria-invalid'?: mixed,
265-
'aria-pressed'?: mixed,
266-
'aria-selected'?: mixed,
267274
'aria-activedescendant'?: mixed,
268275
'aria-atomic'?: mixed,
269276
'aria-autocomplete'?: mixed,
277+
'aria-braillelabel'?: mixed,
278+
'aria-brailleroledescription'?: mixed,
279+
'aria-busy'?: mixed,
280+
'aria-checked'?: mixed,
270281
'aria-colcount'?: mixed,
271282
'aria-colindex'?: mixed,
272283
'aria-colspan'?: mixed,
273284
'aria-controls'?: mixed,
274285
'aria-current'?: ?ARIAPropertyCurrent,
275286
'aria-describedby'?: mixed,
287+
'aria-description'?: mixed,
276288
'aria-details'?: mixed,
289+
'aria-disabled'?: mixed,
277290
'aria-dropeffect'?: mixed,
278291
'aria-errormessage'?: mixed,
292+
'aria-expanded'?: mixed,
279293
'aria-flowto'?: mixed,
294+
'aria-grabbed'?: mixed,
280295
'aria-haspopup'?: mixed,
296+
'aria-hidden'?: mixed,
297+
'aria-invalid'?: mixed,
281298
'aria-keyshortcuts'?: mixed,
282299
'aria-label'?: mixed,
283300
'aria-labelledby'?: mixed,
@@ -290,13 +307,15 @@ type ARIAPropertyMap = {|
290307
'aria-owns'?: mixed,
291308
'aria-placeholder'?: mixed,
292309
'aria-posinset'?: mixed,
310+
'aria-pressed'?: mixed,
293311
'aria-readonly'?: mixed,
294312
'aria-relevant'?: mixed,
295313
'aria-required'?: mixed,
296314
'aria-roledescription'?: mixed,
297315
'aria-rowcount'?: mixed,
298316
'aria-rowindex'?: mixed,
299317
'aria-rowspan'?: mixed,
318+
'aria-selected'?: mixed,
300319
'aria-setsize'?: mixed,
301320
'aria-sort'?: mixed,
302321
'aria-valuemax'?: mixed,
@@ -305,7 +324,7 @@ type ARIAPropertyMap = {|
305324
'aria-valuetext'?: mixed,
306325
|};
307326

308-
type ARIAPropertyDefinition = {
327+
type ARIAPropertyDefinition = {|
309328
type: 'string'
310329
| 'id'
311330
| 'idlist'
@@ -317,7 +336,7 @@ type ARIAPropertyDefinition = {
317336
| 'tristate',
318337
values?: Array<string | boolean>,
319338
allowundefined?: boolean,
320-
};
339+
|};
321340

322341
type ARIAPropertyCurrent =
323342
'page'
@@ -330,31 +349,44 @@ type ARIAPropertyCurrent =
330349
| true
331350
| false;
332351

333-
type ARIARoleRelation = {
352+
type ARIARoleRelation = {|
334353
module?: string,
335354
concept?: ARIARoleRelationConcept,
336-
};
355+
|};
337356

338357
/* The concept in a related domain that informs behavior mappings.
339358
* Related domains include: HTML, "Device Independence Delivery Unit", XForms,
340359
* and ARIA to name a few. */
341-
type ARIARoleRelationConcept = {
360+
type ARIARoleRelationConcept = {|
342361
name: string,
343362
attributes?: Array<ARIARoleRelationConceptAttribute>,
344363
// These constraints are drawn from the mapping between ARIA and HTML:
345364
// https://www.w3.org/TR/html-aria
346-
constraints?: Array<'direct descendant of document'
347-
| 'direct descendant of ol, ul or menu'
365+
constraints?: Array<
366+
| 'scoped to the body element'
367+
| 'scoped to the main element'
368+
| 'scoped to a sectioning root element other than body'
369+
| 'scoped to a sectioning content element'
370+
| 'direct descendant of document'
371+
| 'direct descendant of ol'
372+
| 'direct descendant of ul'
373+
| 'direct descendant of menu'
348374
| 'direct descendant of details element with the open attribute defined'
349-
| 'descendant of table'>,
350-
};
375+
| 'ancestor table element has table role'
376+
| 'ancestor table element has grid role'
377+
| 'ancestor table element has treegrid role'
378+
| 'the progress bar is determinate'
379+
| 'the datalist selection model allows multiple option elements to be selected at a time'
380+
| 'the aria-controls attribute is set to the same value as the list attribute'
381+
| 'the size attribute value is greater than 1'
382+
| 'the multiple attribute value is greater than 1'
383+
| 'the multiple attribute and the size attribute do not have a value greater than 1'
384+
| 'the list attribute is not set'>,
385+
|};
351386

352-
type ARIARoleRelationConceptAttribute = {
387+
type ARIARoleRelationConceptAttribute = {|
353388
name: string,
354389
value?: string | number,
355390
// These constraints are drawn from the mapping between ARIA and HTML:
356391
// https://www.w3.org/TR/html-aria
357-
constraints?: Array<'undefined' // The attribute does not exist on the node: <a>
358-
| 'set' // The attribute has a value: <a b="c">
359-
| '>1'>,
360-
};
392+
|};

0 commit comments

Comments
 (0)