aria-api 0.4.1 → 0.4.2

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/README.md CHANGED
@@ -110,7 +110,7 @@ That said, this is what I think it could also be used for:
110
110
  - [Core Accessibility API Mappings 1.1](https://www.w3.org/TR/core-aam-1.1/)
111
111
  - [HTML Accessibility API Mappings 1.0](https://www.w3.org/TR/html-aam-1.0/)
112
112
  - [WAI-ARIA Graphics Module 1.0](https://www.w3.org/TR/graphics-aria-1.0/)
113
- - [Digital Publishing WAI-ARIA Module 1.0](https://www.w3.org/TR/graphics-aria-1.0/)
113
+ - [Digital Publishing WAI-ARIA Module 1.0](https://www.w3.org/TR/dpub-aria-1.0/)
114
114
  - [Accessible Name and Description Computation 1.1](https://www.w3.org/TR/accname-1.1/)
115
115
 
116
116
  I try to update the code whenever a new version of these specs becomes a
package/dist/aria.js CHANGED
@@ -23,7 +23,7 @@ var attrs = require('./attrs');
23
23
 
24
24
  var _getOwner = function(node) {
25
25
  if (node.nodeType === node.ELEMENT_NODE && node.id) {
26
- var owner = document.querySelector('[aria-owns~="' + node.id + '"]');
26
+ var owner = document.querySelector('[aria-owns~="' + CSS.escape(node.id) + '"]');
27
27
  if (owner) {
28
28
  return owner;
29
29
  }
@@ -46,7 +46,7 @@ var detectLoop = function(node) {
46
46
 
47
47
  var getOwner = function(node) {
48
48
  if (node.nodeType === node.ELEMENT_NODE && node.id) {
49
- var owner = document.querySelector('[aria-owns~="' + node.id + '"]');
49
+ var owner = document.querySelector('[aria-owns~="' + CSS.escape(node.id) + '"]');
50
50
  if (owner && !detectLoop(node)) {
51
51
  return owner;
52
52
  }
@@ -228,62 +228,56 @@ module.exports = {
228
228
  };
229
229
 
230
230
  },{"./constants.js":4}],4:[function(require,module,exports){
231
+ // https://www.w3.org/TR/wai-aria/#state_prop_def
231
232
  exports.attributes = {
232
- // widget
233
+ 'activedescendant': 'id',
234
+ 'atomic': 'bool',
233
235
  'autocomplete': 'token',
236
+ 'busy': 'bool',
234
237
  'checked': 'tristate',
238
+ 'colcount': 'int',
239
+ 'colindex': 'int',
240
+ 'colspan': 'int',
241
+ 'controls': 'id-list',
235
242
  'current': 'token',
243
+ 'describedby': 'id-list',
244
+ 'details': 'id',
236
245
  'disabled': 'bool',
246
+ 'dropeffect': 'token-list',
247
+ 'errormessage': 'id',
237
248
  'expanded': 'bool-undefined',
249
+ 'flowto': 'id-list',
250
+ 'grabbed': 'bool-undefined',
238
251
  'haspopup': 'token',
239
- 'hidden': 'bool', // !
252
+ 'hidden': 'bool-undefined',
240
253
  'invalid': 'token',
241
254
  'keyshortcuts': 'string',
242
255
  'label': 'string',
256
+ 'labelledby': 'id-list',
243
257
  'level': 'int',
258
+ 'live': 'token',
244
259
  'modal': 'bool',
245
260
  'multiline': 'bool',
246
261
  'multiselectable': 'bool',
247
262
  'orientation': 'token',
263
+ 'owns': 'id-list',
248
264
  'placeholder': 'string',
265
+ 'posinset': 'int',
249
266
  'pressed': 'tristate',
250
267
  'readonly': 'bool',
268
+ 'relevant': 'token-list',
251
269
  'required': 'bool',
252
270
  'roledescription': 'string',
253
- 'selected': 'bool-undefined',
254
- 'valuemax': 'number',
255
- 'valuemin': 'number',
256
- 'valuenow': 'number',
257
- 'valuetext': 'string',
258
-
259
- // live
260
- 'atomic': 'bool',
261
- 'busy': 'bool',
262
- 'live': 'token',
263
- 'relevant': 'token-list',
264
-
265
- // dragndrop
266
- 'dropeffect': 'token-list',
267
- 'grabbed': 'bool-undefined',
268
-
269
- // relationship
270
- 'activedescendant': 'id',
271
- 'colcount': 'int',
272
- 'colindex': 'int',
273
- 'colspan': 'int',
274
- 'controls': 'id-list',
275
- 'describedby': 'id-list',
276
- 'details': 'id',
277
- 'errormessage': 'id',
278
- 'flowto': 'id-list',
279
- 'labelledby': 'id-list',
280
- 'owns': 'id-list',
281
- 'posinset': 'int',
282
271
  'rowcount': 'int',
283
272
  'rowindex': 'int',
284
273
  'rowspan': 'int',
274
+ 'selected': 'bool-undefined',
285
275
  'setsize': 'int',
286
276
  'sort': 'token',
277
+ 'valuemax': 'number',
278
+ 'valuemin': 'number',
279
+ 'valuenow': 'number',
280
+ 'valuetext': 'string',
287
281
  };
288
282
 
289
283
  exports.attributeStrongMapping = {
@@ -315,6 +309,9 @@ exports.roles = {
315
309
  article: {
316
310
  selectors: ['article'],
317
311
  },
312
+ blockquote: {
313
+ selectors: ['blockquote'],
314
+ },
318
315
  button: {
319
316
  selectors: [
320
317
  'button',
@@ -326,17 +323,21 @@ exports.roles = {
326
323
  ],
327
324
  nameFromContents: true,
328
325
  },
326
+ caption: {
327
+ selectors: ['caption'], // not sure about figcaption, ARIA and HTML-AAM differ
328
+ },
329
329
  cell: {
330
330
  selectors: ['td'],
331
331
  childRoles: ['gridcell', 'rowheader'],
332
+ nameFromContents: true,
332
333
  },
333
334
  checkbox: {
334
335
  selectors: ['input[type="checkbox"]'],
335
- childRoles: ['menuitemcheckbox', 'switch'],
336
+ childRoles: ['switch'],
336
337
  nameFromContents: true,
337
- defaults: {
338
- 'checked': 'false',
339
- },
338
+ },
339
+ code: {
340
+ selectors: ['code'],
340
341
  },
341
342
  columnheader: {
342
343
  selectors: ['th[scope="col"]'],
@@ -355,7 +356,6 @@ exports.roles = {
355
356
  'select[size="1"]:not([multiple])',
356
357
  ],
357
358
  defaults: {
358
- 'expanded': false,
359
359
  'haspopup': 'listbox',
360
360
  },
361
361
  },
@@ -371,6 +371,9 @@ exports.roles = {
371
371
  definition: {
372
372
  selectors: ['dd'],
373
373
  },
374
+ deletion: {
375
+ selectors: ['del'],
376
+ },
374
377
  dialog: {
375
378
  selectors: ['dialog'],
376
379
  childRoles: ['alertdialog'],
@@ -387,16 +390,35 @@ exports.roles = {
387
390
  'doc-noteref': {
388
391
  nameFromContents: true,
389
392
  },
393
+ 'doc-pagebreak': {
394
+ nameFromContents: true,
395
+ },
396
+ 'doc-subtitle': {
397
+ nameFromContents: true,
398
+ },
390
399
  document: {
391
- selectors: ['body'],
400
+ selector: ['html'],
392
401
  childRoles: ['article', 'graphics-document'],
393
402
  },
403
+ emphasis: {
404
+ selectors: ['em'],
405
+ },
394
406
  figure: {
395
407
  selectors: ['figure'],
408
+ childRoles: ['doc-example'],
396
409
  },
397
410
  form: {
398
411
  selectors: ['form[aria-label]', 'form[aria-labelledby]', 'form[title]'],
399
412
  },
413
+ generic: {
414
+ selectors: [
415
+ 'body',
416
+ 'div',
417
+ 'form:not([aria-label]):not([aria-labelledby]):not([title])',
418
+ 'hgroup',
419
+ 'span',
420
+ ],
421
+ },
400
422
  grid: {
401
423
  childRoles: ['treegrid'],
402
424
  },
@@ -405,22 +427,22 @@ exports.roles = {
405
427
  nameFromContents: true,
406
428
  },
407
429
  group: {
408
- selectors: ['details', 'optgroup'],
430
+ selectors: ['details', 'fieldset', 'optgroup'],
409
431
  childRoles: ['row', 'select', 'toolbar', 'graphics-object'],
410
432
  },
411
433
  heading: {
412
434
  selectors: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
413
435
  nameFromContents: true,
414
- defaults: {
415
- 'level': 2,
416
- },
417
436
  },
418
437
  img: {
419
438
  selectors: ['img:not([alt=""])', 'graphics-symbol'],
420
439
  childRoles: ['doc-cover'],
421
440
  },
422
441
  input: {
423
- childRoles: ['checkbox', 'option', 'radio', 'slider', 'spinbutton', 'textbox'],
442
+ childRoles: ['checkbox', 'combobox', 'option', 'radio', 'slider', 'spinbutton', 'textbox'],
443
+ },
444
+ insertion: {
445
+ selectors: ['ins'],
424
446
  },
425
447
  landmark: {
426
448
  childRoles: [
@@ -456,11 +478,12 @@ exports.roles = {
456
478
  nameFromContents: true,
457
479
  },
458
480
  list: {
459
- selectors: ['dl', 'ol', 'ul'],
481
+ selectors: ['ol', 'ul', 'menu'],
460
482
  childRoles: ['directory', 'feed'],
461
483
  },
462
484
  listbox: {
463
485
  selectors: [
486
+ 'datalist',
464
487
  'select[multiple]',
465
488
  'select[size]:not([size="0"]):not([size="1"])',
466
489
  ],
@@ -469,8 +492,8 @@ exports.roles = {
469
492
  },
470
493
  },
471
494
  listitem: {
472
- selectors: ['dt', 'ul > li', 'ol > li'],
473
- childRoles: ['doc-biblioentry', 'doc-endnote', 'treeitem'],
495
+ selectors: ['ul > li', 'ol > li', 'menu > li'],
496
+ childRoles: ['treeitem'],
474
497
  },
475
498
  log: {
476
499
  defaults: {
@@ -483,8 +506,14 @@ exports.roles = {
483
506
  math: {
484
507
  selectors: ['math'],
485
508
  },
509
+ meter: {
510
+ selectors: ['meter'],
511
+ defaults: {
512
+ 'valuemin': 0,
513
+ 'valuemax': 100,
514
+ },
515
+ },
486
516
  menu: {
487
- selectors: ['menu[type="context"]'],
488
517
  childRoles: ['menubar'],
489
518
  defaults: {
490
519
  'orientation': 'vertical',
@@ -504,16 +533,10 @@ exports.roles = {
504
533
  selectors: ['menuitem[type="checkbox"]'],
505
534
  childRoles: ['menuitemradio'],
506
535
  nameFromContents: true,
507
- defaults: {
508
- 'checked': 'false',
509
- },
510
536
  },
511
537
  menuitemradio: {
512
538
  selectors: ['menuitem[type="radio"]'],
513
539
  nameFromContents: true,
514
- defaults: {
515
- 'checked': 'false',
516
- },
517
540
  },
518
541
  navigation: {
519
542
  selectors: ['nav'],
@@ -530,19 +553,22 @@ exports.roles = {
530
553
  'selected': 'false',
531
554
  },
532
555
  },
556
+ paragraph: {
557
+ selectors: ['p'],
558
+ },
533
559
  progressbar: {
534
560
  selectors: ['progress'],
561
+ defaults: {
562
+ 'valuemin': 0,
563
+ 'valuemax': 100,
564
+ },
535
565
  },
536
566
  radio: {
537
567
  selectors: ['input[type="radio"]'],
538
- childRoles: ['menuitemradio'],
539
568
  nameFromContents: true,
540
- defaults: {
541
- 'checked': 'false',
542
- },
543
569
  },
544
570
  range: {
545
- childRoles: ['progressbar', 'scrollbar', 'slider', 'spinbutton'],
571
+ childRoles: ['meter', 'progressbar', 'scrollbar', 'slider', 'spinbutton'],
546
572
  },
547
573
  region: {
548
574
  selectors: ['section[aria-label]', 'section[aria-labelledby]', 'section[title]'],
@@ -554,12 +580,11 @@ exports.roles = {
554
580
  selectors: ['tr'],
555
581
  nameFromContents: true,
556
582
  },
557
- rowheader: {
558
- selectors: ['th[scope="row"]'],
559
- nameFromContents: true,
560
- },
561
583
  rowgroup: {
562
584
  selectors: ['tbody', 'thead', 'tfoot'],
585
+ },
586
+ rowheader: {
587
+ selectors: ['th[scope="row"]'],
563
588
  nameFromContents: true,
564
589
  },
565
590
  scrollbar: {
@@ -577,19 +602,27 @@ exports.roles = {
577
602
  section: {
578
603
  childRoles: [
579
604
  'alert',
605
+ 'blockquote',
606
+ 'caption',
580
607
  'cell',
608
+ 'code',
581
609
  'definition',
610
+ 'deletion',
582
611
  'doc-abstract',
583
612
  'doc-colophon',
584
613
  'doc-credit',
585
614
  'doc-dedication',
586
615
  'doc-epigraph',
587
- 'doc-example',
588
616
  'doc-footnote',
617
+ 'doc-pagefooter',
618
+ 'doc-pageheader',
619
+ 'doc-pullquote',
589
620
  'doc-qna',
621
+ 'emphasis',
590
622
  'figure',
591
623
  'group',
592
624
  'img',
625
+ 'insertion',
593
626
  'landmark',
594
627
  'list',
595
628
  'listitem',
@@ -597,10 +630,15 @@ exports.roles = {
597
630
  'marquee',
598
631
  'math',
599
632
  'note',
633
+ 'paragraph',
600
634
  'status',
635
+ 'strong',
636
+ 'subscript',
637
+ 'superscript',
601
638
  'table',
602
639
  'tabpanel',
603
640
  'term',
641
+ 'time',
604
642
  'tooltip',
605
643
  ],
606
644
  },
@@ -615,16 +653,14 @@ exports.roles = {
615
653
  nameFromContents: true,
616
654
  },
617
655
  select: {
618
- childRoles: ['combobox', 'listbox', 'menu', 'radiogroup', 'tree'],
656
+ childRoles: ['listbox', 'menu', 'radiogroup', 'tree'],
619
657
  },
620
658
  separator: {
659
+ // assume not focussable because <hr> is not
621
660
  selectors: ['hr'],
622
661
  childRoles: ['doc-pagebreak'],
623
662
  defaults: {
624
663
  'orientation': 'horizontal',
625
- 'valuemin': 0,
626
- 'valuemax': 100,
627
- 'valuenow': 50,
628
664
  },
629
665
  },
630
666
  slider: {
@@ -640,8 +676,7 @@ exports.roles = {
640
676
  spinbutton: {
641
677
  selectors: ['input[type="number"]'],
642
678
  defaults: {
643
- // FIXME: no valuemin/valuemax
644
- 'valuenow': 0,
679
+ // FIXME: no valuemin/valuemax/valuenow
645
680
  },
646
681
  },
647
682
  status: {
@@ -652,24 +687,32 @@ exports.roles = {
652
687
  'atomic': true,
653
688
  },
654
689
  },
655
- switch: {
656
- nameFromContents: true,
657
- defaults: {
658
- 'checked': false,
659
- },
690
+ strong: {
691
+ selectors: ['strong'],
660
692
  },
661
693
  structure: {
662
694
  childRoles: [
663
695
  'application',
664
696
  'document',
665
697
  'none',
698
+ 'generic',
666
699
  'presentation',
700
+ 'range',
667
701
  'rowgroup',
668
702
  'section',
669
703
  'sectionhead',
670
704
  'separator',
671
705
  ],
672
706
  },
707
+ subscript: {
708
+ selectors: ['sub'],
709
+ },
710
+ superscript: {
711
+ selectors: ['sup'],
712
+ },
713
+ switch: {
714
+ nameFromContents: true,
715
+ },
673
716
  tab: {
674
717
  nameFromContents: true,
675
718
  defaults: {
@@ -699,6 +742,9 @@ exports.roles = {
699
742
  ],
700
743
  childRoles: ['searchbox'],
701
744
  },
745
+ time: {
746
+ selectors: ['time'],
747
+ },
702
748
  toolbar: {
703
749
  defaults: {
704
750
  'orientation': 'horizontal',
@@ -722,9 +768,9 @@ exports.roles = {
722
768
  'composite',
723
769
  'gridcell',
724
770
  'input',
725
- 'range',
771
+ 'progressbar',
726
772
  'row',
727
- 'separator',
773
+ 'scrollbar',
728
774
  'tab',
729
775
  ],
730
776
  },
package/lib/atree.js CHANGED
@@ -2,7 +2,7 @@ var attrs = require('./attrs');
2
2
 
3
3
  var _getOwner = function(node) {
4
4
  if (node.nodeType === node.ELEMENT_NODE && node.id) {
5
- var owner = document.querySelector('[aria-owns~="' + node.id + '"]');
5
+ var owner = document.querySelector('[aria-owns~="' + CSS.escape(node.id) + '"]');
6
6
  if (owner) {
7
7
  return owner;
8
8
  }
@@ -25,7 +25,7 @@ var detectLoop = function(node) {
25
25
 
26
26
  var getOwner = function(node) {
27
27
  if (node.nodeType === node.ELEMENT_NODE && node.id) {
28
- var owner = document.querySelector('[aria-owns~="' + node.id + '"]');
28
+ var owner = document.querySelector('[aria-owns~="' + CSS.escape(node.id) + '"]');
29
29
  if (owner && !detectLoop(node)) {
30
30
  return owner;
31
31
  }
package/lib/constants.js CHANGED
@@ -1,59 +1,53 @@
1
+ // https://www.w3.org/TR/wai-aria/#state_prop_def
1
2
  exports.attributes = {
2
- // widget
3
+ 'activedescendant': 'id',
4
+ 'atomic': 'bool',
3
5
  'autocomplete': 'token',
6
+ 'busy': 'bool',
4
7
  'checked': 'tristate',
8
+ 'colcount': 'int',
9
+ 'colindex': 'int',
10
+ 'colspan': 'int',
11
+ 'controls': 'id-list',
5
12
  'current': 'token',
13
+ 'describedby': 'id-list',
14
+ 'details': 'id',
6
15
  'disabled': 'bool',
16
+ 'dropeffect': 'token-list',
17
+ 'errormessage': 'id',
7
18
  'expanded': 'bool-undefined',
19
+ 'flowto': 'id-list',
20
+ 'grabbed': 'bool-undefined',
8
21
  'haspopup': 'token',
9
- 'hidden': 'bool', // !
22
+ 'hidden': 'bool-undefined',
10
23
  'invalid': 'token',
11
24
  'keyshortcuts': 'string',
12
25
  'label': 'string',
26
+ 'labelledby': 'id-list',
13
27
  'level': 'int',
28
+ 'live': 'token',
14
29
  'modal': 'bool',
15
30
  'multiline': 'bool',
16
31
  'multiselectable': 'bool',
17
32
  'orientation': 'token',
33
+ 'owns': 'id-list',
18
34
  'placeholder': 'string',
35
+ 'posinset': 'int',
19
36
  'pressed': 'tristate',
20
37
  'readonly': 'bool',
38
+ 'relevant': 'token-list',
21
39
  'required': 'bool',
22
40
  'roledescription': 'string',
23
- 'selected': 'bool-undefined',
24
- 'valuemax': 'number',
25
- 'valuemin': 'number',
26
- 'valuenow': 'number',
27
- 'valuetext': 'string',
28
-
29
- // live
30
- 'atomic': 'bool',
31
- 'busy': 'bool',
32
- 'live': 'token',
33
- 'relevant': 'token-list',
34
-
35
- // dragndrop
36
- 'dropeffect': 'token-list',
37
- 'grabbed': 'bool-undefined',
38
-
39
- // relationship
40
- 'activedescendant': 'id',
41
- 'colcount': 'int',
42
- 'colindex': 'int',
43
- 'colspan': 'int',
44
- 'controls': 'id-list',
45
- 'describedby': 'id-list',
46
- 'details': 'id',
47
- 'errormessage': 'id',
48
- 'flowto': 'id-list',
49
- 'labelledby': 'id-list',
50
- 'owns': 'id-list',
51
- 'posinset': 'int',
52
41
  'rowcount': 'int',
53
42
  'rowindex': 'int',
54
43
  'rowspan': 'int',
44
+ 'selected': 'bool-undefined',
55
45
  'setsize': 'int',
56
46
  'sort': 'token',
47
+ 'valuemax': 'number',
48
+ 'valuemin': 'number',
49
+ 'valuenow': 'number',
50
+ 'valuetext': 'string',
57
51
  };
58
52
 
59
53
  exports.attributeStrongMapping = {
@@ -99,6 +93,7 @@ exports.roles = {
99
93
  cell: {
100
94
  selectors: ['td'],
101
95
  childRoles: ['gridcell', 'rowheader'],
96
+ nameFromContents: true,
102
97
  },
103
98
  checkbox: {
104
99
  selectors: ['input[type="checkbox"]'],
@@ -324,14 +319,14 @@ exports.roles = {
324
319
  selectors: ['tr'],
325
320
  nameFromContents: true,
326
321
  },
327
- rowheader: {
328
- selectors: ['th[scope="row"]'],
329
- nameFromContents: true,
330
- },
331
322
  rowgroup: {
332
323
  selectors: ['tbody', 'thead', 'tfoot'],
333
324
  nameFromContents: true,
334
325
  },
326
+ rowheader: {
327
+ selectors: ['th[scope="row"]'],
328
+ nameFromContents: true,
329
+ },
335
330
  scrollbar: {
336
331
  defaults: {
337
332
  'orientation': 'vertical',
@@ -388,13 +383,11 @@ exports.roles = {
388
383
  childRoles: ['combobox', 'listbox', 'menu', 'radiogroup', 'tree'],
389
384
  },
390
385
  separator: {
386
+ // assume not focussable because <hr> is not
391
387
  selectors: ['hr'],
392
388
  childRoles: ['doc-pagebreak'],
393
389
  defaults: {
394
390
  'orientation': 'horizontal',
395
- 'valuemin': 0,
396
- 'valuemax': 100,
397
- 'valuenow': 50,
398
391
  },
399
392
  },
400
393
  slider: {
@@ -422,12 +415,6 @@ exports.roles = {
422
415
  'atomic': true,
423
416
  },
424
417
  },
425
- switch: {
426
- nameFromContents: true,
427
- defaults: {
428
- 'checked': false,
429
- },
430
- },
431
418
  structure: {
432
419
  childRoles: [
433
420
  'application',
@@ -440,6 +427,12 @@ exports.roles = {
440
427
  'separator',
441
428
  ],
442
429
  },
430
+ switch: {
431
+ nameFromContents: true,
432
+ defaults: {
433
+ 'checked': false,
434
+ },
435
+ },
443
436
  tab: {
444
437
  nameFromContents: true,
445
438
  defaults: {
@@ -494,7 +487,6 @@ exports.roles = {
494
487
  'input',
495
488
  'range',
496
489
  'row',
497
- 'separator',
498
490
  'tab',
499
491
  ],
500
492
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aria-api",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Access ARIA information from JavaScript",
5
5
  "main": "index.js",
6
6
  "keywords": [