aria-api 0.4.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/constants.js CHANGED
@@ -66,13 +66,8 @@ exports.attributeWeakMapping = {
66
66
  'selected': 'selected',
67
67
  };
68
68
 
69
- var scoped = [
70
- 'main *',
71
- // https://www.w3.org/TR/html/dom.html#sectioning-content-2
72
- 'article *', 'aside *', 'nav *', 'section *',
73
- // https://www.w3.org/TR/html/sections.html#sectioning-roots
74
- 'blockquote *', 'details *', 'dialog *', 'fieldset *', 'figure *', 'td *',
75
- ].join(',');
69
+ // https://www.w3.org/TR/html/dom.html#sectioning-content-2
70
+ const scoped = ['article *', 'aside *', 'nav *', 'section *'].join(',');
76
71
 
77
72
  // https://www.w3.org/TR/html-aam-1.0/#html-element-role-mappings
78
73
  // https://www.w3.org/TR/wai-aria/roles
@@ -84,11 +79,16 @@ exports.roles = {
84
79
  'atomic': true,
85
80
  },
86
81
  },
82
+ alertdialog: {},
83
+ application: {},
87
84
  article: {
88
85
  selectors: ['article'],
89
86
  },
90
87
  banner: {
91
- selectors: ['header:not(' + scoped + ')'],
88
+ selectors: [`header:not(main *, ${scoped})`],
89
+ },
90
+ blockquote: {
91
+ selectors: ['blockquote'],
92
92
  },
93
93
  button: {
94
94
  selectors: [
@@ -101,26 +101,32 @@ exports.roles = {
101
101
  ],
102
102
  nameFromContents: true,
103
103
  },
104
+ caption: {
105
+ selectors: ['caption', 'figcaption'],
106
+ },
104
107
  cell: {
105
- selectors: ['td'],
106
- childRoles: ['gridcell', 'rowheader'],
108
+ selectors: ['td', 'td ~ th:not([scope])'],
109
+ childRoles: ['columnheader', 'gridcell', 'rowheader'],
107
110
  nameFromContents: true,
108
111
  },
109
112
  checkbox: {
110
113
  selectors: ['input[type="checkbox"]'],
111
- childRoles: ['menuitemcheckbox', 'switch'],
114
+ childRoles: ['switch'],
112
115
  nameFromContents: true,
113
116
  defaults: {
114
117
  'checked': 'false',
115
118
  },
116
119
  },
120
+ code: {
121
+ selectors: ['code'],
122
+ },
117
123
  columnheader: {
118
124
  selectors: ['th[scope="col"]'],
119
125
  nameFromContents: true,
120
126
  },
121
127
  combobox: {
122
128
  selectors: [
123
- 'input:not([type])[list]',
129
+ 'input:not([type])[list]',
124
130
  'input[type="email"][list]',
125
131
  'input[type="search"][list]',
126
132
  'input[type="tel"][list]',
@@ -136,46 +142,131 @@ exports.roles = {
136
142
  },
137
143
  },
138
144
  command: {
145
+ abstract: true,
139
146
  childRoles: ['button', 'link', 'menuitem'],
140
147
  },
141
148
  complementary: {
142
- selectors: ['aside'],
149
+ selectors: [
150
+ `aside:not(${scoped})`,
151
+ 'aside[aria-label]',
152
+ 'aside[aria-labelledby]',
153
+ 'aside[title]',
154
+ ],
143
155
  },
144
156
  composite: {
157
+ abstract: true,
145
158
  childRoles: ['grid', 'select', 'spinbutton', 'tablist'],
146
159
  },
147
160
  contentinfo: {
148
- selectors: ['footer:not(' + scoped + ')'],
161
+ selectors: [`footer:not(main *, ${scoped})`],
149
162
  },
150
163
  definition: {
151
164
  selectors: ['dd'],
152
165
  },
166
+ deletion: {
167
+ selectors: ['del', 's'],
168
+ },
153
169
  dialog: {
154
170
  selectors: ['dialog'],
155
171
  childRoles: ['alertdialog'],
156
172
  },
173
+ 'doc-abstract': {},
174
+ 'doc-acknowledgments': {},
175
+ 'doc-afterword': {},
176
+ 'doc-appendix': {},
157
177
  'doc-backlink': {
158
178
  nameFromContents: true,
159
179
  },
180
+ 'doc-biblioentry': {},
181
+ 'doc-bibliography': {},
160
182
  'doc-biblioref': {
161
183
  nameFromContents: true,
162
184
  },
185
+ 'doc-chapter': {},
186
+ 'doc-colophon': {},
187
+ 'doc-conclusion': {},
188
+ 'doc-cover': {},
189
+ 'doc-credit': {},
190
+ 'doc-credits': {},
191
+ 'doc-dedication': {},
192
+ 'doc-endnote': {},
193
+ 'doc-endnotes': {},
194
+ 'doc-epilogue': {},
195
+ 'doc-epigraph': {},
196
+ 'doc-errata': {},
197
+ 'doc-example': {},
198
+ 'doc-footnote': {},
199
+ 'doc-foreword': {},
200
+ 'doc-glossary': {},
163
201
  'doc-glossref': {
164
202
  nameFromContents: true,
165
203
  },
204
+ 'doc-index': {},
205
+ 'doc-introduction': {},
166
206
  'doc-noteref': {
167
207
  nameFromContents: true,
168
208
  },
209
+ 'doc-notice': {},
210
+ 'doc-pagebreak': {
211
+ nameFromContents: true,
212
+ },
213
+ 'doc-pagefooter': {},
214
+ 'doc-pageheader': {},
215
+ 'doc-pagelist': {},
216
+ 'doc-part': {},
217
+ 'doc-preface': {},
218
+ 'doc-prologue': {},
219
+ 'doc-pullquote': {},
220
+ 'doc-qna': {},
221
+ 'doc-subtitle': {
222
+ nameFromContents: true,
223
+ },
224
+ 'doc-tip': {},
225
+ 'doc-toc': {},
169
226
  document: {
170
- selectors: ['body'],
227
+ selectors: ['html'],
171
228
  childRoles: ['article', 'graphics-document'],
172
229
  },
230
+ emphasis: {
231
+ selectors: ['em'],
232
+ },
233
+ feed: {},
173
234
  figure: {
174
235
  selectors: ['figure'],
236
+ childRoles: ['doc-example'],
175
237
  },
176
238
  form: {
177
239
  selectors: ['form[aria-label]', 'form[aria-labelledby]', 'form[title]'],
178
240
  },
241
+ generic: {
242
+ selectors: [
243
+ 'a:not([href])',
244
+ 'area:not([href])',
245
+ `aside:not(${scoped}):not([aria-label]):not([aria-labelledby]):not([title])`,
246
+ 'b',
247
+ 'bdi',
248
+ 'bdo',
249
+ 'body',
250
+ 'data',
251
+ 'div',
252
+ // footer scoped
253
+ // header scoped
254
+ 'i',
255
+ 'li:not(ul > li):not(ol > li)',
256
+ 'pre',
257
+ 'q',
258
+ 'samp',
259
+ 'section:not([aria-label]):not([aria-labelledby]):not([title])',
260
+ 'small',
261
+ 'span',
262
+ 'u',
263
+ ],
264
+ },
265
+ 'graphics-document': {
266
+ selectors: ['svg'],
267
+ },
268
+ 'graphics-object': {},
269
+ 'graphics-symbol': {},
179
270
  grid: {
180
271
  childRoles: ['treegrid'],
181
272
  },
@@ -184,7 +275,14 @@ exports.roles = {
184
275
  nameFromContents: true,
185
276
  },
186
277
  group: {
187
- selectors: ['details', 'optgroup'],
278
+ selectors: [
279
+ 'address',
280
+ 'details',
281
+ 'fieldset',
282
+ 'hgroup',
283
+ 'optgroup',
284
+ 'text',
285
+ ],
188
286
  childRoles: ['row', 'select', 'toolbar', 'graphics-object'],
189
287
  },
190
288
  heading: {
@@ -199,9 +297,22 @@ exports.roles = {
199
297
  childRoles: ['doc-cover'],
200
298
  },
201
299
  input: {
202
- childRoles: ['checkbox', 'option', 'radio', 'slider', 'spinbutton', 'textbox'],
300
+ abstract: true,
301
+ childRoles: [
302
+ 'checkbox',
303
+ 'combobox',
304
+ 'option',
305
+ 'radio',
306
+ 'slider',
307
+ 'spinbutton',
308
+ 'textbox',
309
+ ],
310
+ },
311
+ insertion: {
312
+ selectors: ['ins'],
203
313
  },
204
314
  landmark: {
315
+ abstract: true,
205
316
  childRoles: [
206
317
  'banner',
207
318
  'complementary',
@@ -230,16 +341,17 @@ exports.roles = {
230
341
  ],
231
342
  },
232
343
  link: {
233
- selectors: ['a[href]', 'area[href]', 'link[href]'],
344
+ selectors: ['a[href]', 'area[href]'],
234
345
  childRoles: ['doc-backlink', 'doc-biblioref', 'doc-glossref', 'doc-noteref'],
235
346
  nameFromContents: true,
236
347
  },
237
348
  list: {
238
- selectors: ['dl', 'ol', 'ul'],
239
- childRoles: ['directory', 'feed'],
349
+ selectors: ['dl', 'ol', 'ul', 'menu'],
350
+ childRoles: ['feed'],
240
351
  },
241
352
  listbox: {
242
353
  selectors: [
354
+ 'datalist',
243
355
  'select[multiple]',
244
356
  'select[size]:not([size="0"]):not([size="1"])',
245
357
  ],
@@ -248,7 +360,7 @@ exports.roles = {
248
360
  },
249
361
  },
250
362
  listitem: {
251
- selectors: ['dt', 'ul > li', 'ol > li'],
363
+ selectors: ['ol > li', 'ul > li'],
252
364
  childRoles: ['doc-biblioentry', 'doc-endnote', 'treeitem'],
253
365
  },
254
366
  log: {
@@ -259,11 +371,18 @@ exports.roles = {
259
371
  main: {
260
372
  selectors: ['main'],
261
373
  },
374
+ marquee: {},
262
375
  math: {
263
376
  selectors: ['math'],
264
377
  },
378
+ meter: {
379
+ selectors: ['meter'],
380
+ defaults: {
381
+ 'valuemin': 0,
382
+ 'valuemax': 100,
383
+ },
384
+ },
265
385
  menu: {
266
- selectors: ['menu[type="context"]'],
267
386
  childRoles: ['menubar'],
268
387
  defaults: {
269
388
  'orientation': 'vertical',
@@ -275,12 +394,10 @@ exports.roles = {
275
394
  },
276
395
  },
277
396
  menuitem: {
278
- selectors: ['menuitem[type="command"]'],
279
397
  childRoles: ['menuitemcheckbox'],
280
398
  nameFromContents: true,
281
399
  },
282
400
  menuitemcheckbox: {
283
- selectors: ['menuitem[type="checkbox"]'],
284
401
  childRoles: ['menuitemradio'],
285
402
  nameFromContents: true,
286
403
  defaults: {
@@ -288,7 +405,6 @@ exports.roles = {
288
405
  },
289
406
  },
290
407
  menuitemradio: {
291
- selectors: ['menuitem[type="radio"]'],
292
408
  nameFromContents: true,
293
409
  defaults: {
294
410
  'checked': 'false',
@@ -298,6 +414,9 @@ exports.roles = {
298
414
  selectors: ['nav'],
299
415
  childRoles: ['doc-index', 'doc-pagelist', 'doc-toc'],
300
416
  },
417
+ none: {
418
+ selectors: ['img[alt=""]'],
419
+ },
301
420
  note: {
302
421
  childRoles: ['doc-notice', 'doc-tip'],
303
422
  },
@@ -309,11 +428,15 @@ exports.roles = {
309
428
  'selected': 'false',
310
429
  },
311
430
  },
312
- presentation: {
313
- selectors: ['img[alt=""]'],
431
+ paragraph: {
432
+ selectors: ['p'],
314
433
  },
315
434
  progressbar: {
316
435
  selectors: ['progress'],
436
+ defaults: {
437
+ 'valuemin': 0,
438
+ 'valuemax': 100,
439
+ },
317
440
  },
318
441
  radio: {
319
442
  selectors: ['input[type="radio"]'],
@@ -323,13 +446,16 @@ exports.roles = {
323
446
  'checked': 'false',
324
447
  },
325
448
  },
449
+ radiogroup: {},
326
450
  range: {
327
- childRoles: ['progressbar', 'scrollbar', 'slider', 'spinbutton'],
451
+ abstract: true,
452
+ childRoles: ['meter', 'progressbar', 'scrollbar', 'slider', 'spinbutton'],
328
453
  },
329
454
  region: {
330
455
  selectors: ['section[aria-label]', 'section[aria-labelledby]', 'section[title]'],
331
456
  },
332
457
  roletype: {
458
+ abstract: true,
333
459
  childRoles: ['structure', 'widget', 'window'],
334
460
  },
335
461
  row: {
@@ -338,10 +464,9 @@ exports.roles = {
338
464
  },
339
465
  rowgroup: {
340
466
  selectors: ['tbody', 'thead', 'tfoot'],
341
- nameFromContents: true,
342
467
  },
343
468
  rowheader: {
344
- selectors: ['th[scope="row"]'],
469
+ selectors: ['th[scope="row"]', 'th:not([scope]):not(td ~ th)'],
345
470
  nameFromContents: true,
346
471
  },
347
472
  scrollbar: {
@@ -349,29 +474,39 @@ exports.roles = {
349
474
  'orientation': 'vertical',
350
475
  'valuemin': 0,
351
476
  'valuemax': 100,
352
- // FIXME: halfway between actual valuemin and valuemax
353
- 'valuenow': 50,
354
477
  },
355
478
  },
479
+ search: {
480
+ selectors: ['search'],
481
+ },
356
482
  searchbox: {
357
483
  selectors: ['input[type="search"]:not([list])'],
358
484
  },
359
485
  section: {
486
+ abstract: true,
360
487
  childRoles: [
361
488
  'alert',
489
+ 'blockquote',
490
+ 'caption',
362
491
  'cell',
492
+ 'code',
363
493
  'definition',
494
+ 'deletion',
364
495
  'doc-abstract',
365
496
  'doc-colophon',
366
497
  'doc-credit',
367
498
  'doc-dedication',
368
499
  'doc-epigraph',
369
- 'doc-example',
370
500
  'doc-footnote',
501
+ 'doc-pagefooter',
502
+ 'doc-pageheader',
503
+ 'doc-pullquote',
371
504
  'doc-qna',
505
+ 'emphasis',
372
506
  'figure',
373
507
  'group',
374
508
  'img',
509
+ 'insertion',
375
510
  'landmark',
376
511
  'list',
377
512
  'listitem',
@@ -379,14 +514,20 @@ exports.roles = {
379
514
  'marquee',
380
515
  'math',
381
516
  'note',
517
+ 'paragraph',
382
518
  'status',
519
+ 'strong',
520
+ 'subscript',
521
+ 'superscript',
383
522
  'table',
384
523
  'tabpanel',
385
524
  'term',
525
+ 'time',
386
526
  'tooltip',
387
527
  ],
388
528
  },
389
529
  sectionhead: {
530
+ abstract: true,
390
531
  childRoles: [
391
532
  'columnheader',
392
533
  'doc-subtitle',
@@ -397,7 +538,8 @@ exports.roles = {
397
538
  nameFromContents: true,
398
539
  },
399
540
  select: {
400
- childRoles: ['combobox', 'listbox', 'menu', 'radiogroup', 'tree'],
541
+ abstract: true,
542
+ childRoles: ['listbox', 'menu', 'radiogroup', 'tree'],
401
543
  },
402
544
  separator: {
403
545
  // assume not focussable because <hr> is not
@@ -405,6 +547,8 @@ exports.roles = {
405
547
  childRoles: ['doc-pagebreak'],
406
548
  defaults: {
407
549
  'orientation': 'horizontal',
550
+ 'valuemin': 0,
551
+ 'valuemax': 100,
408
552
  },
409
553
  },
410
554
  slider: {
@@ -420,8 +564,7 @@ exports.roles = {
420
564
  spinbutton: {
421
565
  selectors: ['input[type="number"]'],
422
566
  defaults: {
423
- // FIXME: no valuemin/valuemax
424
- 'valuenow': 0,
567
+ // FIXME: no valuemin/valuemax/valuenow
425
568
  },
426
569
  },
427
570
  status: {
@@ -432,18 +575,30 @@ exports.roles = {
432
575
  'atomic': true,
433
576
  },
434
577
  },
578
+ strong: {
579
+ selectors: ['strong'],
580
+ },
435
581
  structure: {
582
+ abstract: true,
436
583
  childRoles: [
437
584
  'application',
438
585
  'document',
439
586
  'none',
440
- 'presentation',
587
+ 'generic',
588
+ 'range',
441
589
  'rowgroup',
442
590
  'section',
443
591
  'sectionhead',
444
592
  'separator',
445
593
  ],
446
594
  },
595
+ suggestion: {},
596
+ subscript: {
597
+ selectors: ['sub'],
598
+ },
599
+ superscript: {
600
+ selectors: ['sup'],
601
+ },
447
602
  switch: {
448
603
  nameFromContents: true,
449
604
  defaults: {
@@ -465,6 +620,7 @@ exports.roles = {
465
620
  'orientation': 'horizontal',
466
621
  },
467
622
  },
623
+ tabpanel: {},
468
624
  term: {
469
625
  selectors: ['dfn', 'dt'],
470
626
  },
@@ -479,6 +635,14 @@ exports.roles = {
479
635
  ],
480
636
  childRoles: ['searchbox'],
481
637
  },
638
+ time: {
639
+ selectors: ['time'],
640
+ },
641
+ timer: {
642
+ defaults: {
643
+ 'live': 'off',
644
+ },
645
+ },
482
646
  toolbar: {
483
647
  defaults: {
484
648
  'orientation': 'horizontal',
@@ -493,30 +657,35 @@ exports.roles = {
493
657
  'orientation': 'vertical',
494
658
  },
495
659
  },
660
+ treegrid: {},
496
661
  treeitem: {
497
662
  nameFromContents: true,
498
663
  },
499
664
  widget: {
665
+ abstract: true,
500
666
  childRoles: [
501
667
  'command',
502
668
  'composite',
503
669
  'gridcell',
504
670
  'input',
505
- 'range',
671
+ 'progressbar',
506
672
  'row',
673
+ 'scrollbar',
674
+ 'separator',
507
675
  'tab',
508
676
  ],
509
677
  },
510
678
  window: {
679
+ abstract: true,
511
680
  childRoles: ['dialog'],
512
681
  },
513
682
  };
514
683
 
515
- var getSubRoles = function(role) {
516
- var children = (exports.roles[role] || {}).childRoles || [];
517
- var descendents = children.map(getSubRoles);
684
+ const getSubRoles = function(role) {
685
+ const children = (exports.roles[role]).childRoles || [];
686
+ const descendents = children.map(getSubRoles);
518
687
 
519
- var result = [role];
688
+ const result = [role];
520
689
 
521
690
  descendents.forEach(list => {
522
691
  list.forEach(r => {
@@ -531,18 +700,19 @@ var getSubRoles = function(role) {
531
700
 
532
701
  exports.attrsWithDefaults = [];
533
702
 
534
- for (var role in exports.roles) {
703
+ for (const role in exports.roles) {
535
704
  exports.roles[role].subRoles = getSubRoles(role);
536
- for (var key in exports.roles[role].defaults) {
705
+ for (const key in exports.roles[role].defaults) {
537
706
  if (!exports.attrsWithDefaults.includes(key)) {
538
707
  exports.attrsWithDefaults.push(key);
539
708
  }
540
709
  }
541
710
  }
542
- exports.roles['none'] = exports.roles['none'] || {};
543
- exports.roles['none'].subRoles = ['none', 'presentation'];
544
- exports.roles['presentation'] = exports.roles['presentation'] || {};
545
- exports.roles['presentation'].subRoles = ['presentation', 'none'];
711
+
712
+ exports.aliases = {
713
+ 'presentation': 'none',
714
+ 'directory': 'list',
715
+ };
546
716
 
547
717
  exports.nameFromDescendant = {
548
718
  'figure': 'figcaption',