aria-api 0.4.2 → 0.4.4
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/dist/aria.js +44 -111
- package/lib/atree.js +4 -4
- package/lib/attrs.js +3 -0
- package/lib/constants.js +0 -11
- package/lib/name.js +2 -7
- package/package.json +1 -1
package/dist/aria.js
CHANGED
|
@@ -35,12 +35,12 @@ var _getParentNode = function(node) {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
var detectLoop = function(node) {
|
|
38
|
-
var
|
|
39
|
-
while (
|
|
40
|
-
if (
|
|
38
|
+
var seen = [node]
|
|
39
|
+
while ((node = _getParentNode(node))) {
|
|
40
|
+
if (seen.includes(node)) {
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
seen.push(node)
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -163,6 +163,9 @@ var getAttribute = function(el, key) {
|
|
|
163
163
|
if (el.matches('noscript')) {
|
|
164
164
|
return true;
|
|
165
165
|
}
|
|
166
|
+
if (el.matches('details:not([open]) :not(summary)')) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
166
169
|
var style = window.getComputedStyle(el);
|
|
167
170
|
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
168
171
|
return true;
|
|
@@ -309,9 +312,6 @@ exports.roles = {
|
|
|
309
312
|
article: {
|
|
310
313
|
selectors: ['article'],
|
|
311
314
|
},
|
|
312
|
-
blockquote: {
|
|
313
|
-
selectors: ['blockquote'],
|
|
314
|
-
},
|
|
315
315
|
button: {
|
|
316
316
|
selectors: [
|
|
317
317
|
'button',
|
|
@@ -323,9 +323,6 @@ exports.roles = {
|
|
|
323
323
|
],
|
|
324
324
|
nameFromContents: true,
|
|
325
325
|
},
|
|
326
|
-
caption: {
|
|
327
|
-
selectors: ['caption'], // not sure about figcaption, ARIA and HTML-AAM differ
|
|
328
|
-
},
|
|
329
326
|
cell: {
|
|
330
327
|
selectors: ['td'],
|
|
331
328
|
childRoles: ['gridcell', 'rowheader'],
|
|
@@ -333,11 +330,11 @@ exports.roles = {
|
|
|
333
330
|
},
|
|
334
331
|
checkbox: {
|
|
335
332
|
selectors: ['input[type="checkbox"]'],
|
|
336
|
-
childRoles: ['switch'],
|
|
333
|
+
childRoles: ['menuitemcheckbox', 'switch'],
|
|
337
334
|
nameFromContents: true,
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
335
|
+
defaults: {
|
|
336
|
+
'checked': 'false',
|
|
337
|
+
},
|
|
341
338
|
},
|
|
342
339
|
columnheader: {
|
|
343
340
|
selectors: ['th[scope="col"]'],
|
|
@@ -356,6 +353,7 @@ exports.roles = {
|
|
|
356
353
|
'select[size="1"]:not([multiple])',
|
|
357
354
|
],
|
|
358
355
|
defaults: {
|
|
356
|
+
'expanded': false,
|
|
359
357
|
'haspopup': 'listbox',
|
|
360
358
|
},
|
|
361
359
|
},
|
|
@@ -371,9 +369,6 @@ exports.roles = {
|
|
|
371
369
|
definition: {
|
|
372
370
|
selectors: ['dd'],
|
|
373
371
|
},
|
|
374
|
-
deletion: {
|
|
375
|
-
selectors: ['del'],
|
|
376
|
-
},
|
|
377
372
|
dialog: {
|
|
378
373
|
selectors: ['dialog'],
|
|
379
374
|
childRoles: ['alertdialog'],
|
|
@@ -390,35 +385,16 @@ exports.roles = {
|
|
|
390
385
|
'doc-noteref': {
|
|
391
386
|
nameFromContents: true,
|
|
392
387
|
},
|
|
393
|
-
'doc-pagebreak': {
|
|
394
|
-
nameFromContents: true,
|
|
395
|
-
},
|
|
396
|
-
'doc-subtitle': {
|
|
397
|
-
nameFromContents: true,
|
|
398
|
-
},
|
|
399
388
|
document: {
|
|
400
|
-
|
|
389
|
+
selectors: ['body'],
|
|
401
390
|
childRoles: ['article', 'graphics-document'],
|
|
402
391
|
},
|
|
403
|
-
emphasis: {
|
|
404
|
-
selectors: ['em'],
|
|
405
|
-
},
|
|
406
392
|
figure: {
|
|
407
393
|
selectors: ['figure'],
|
|
408
|
-
childRoles: ['doc-example'],
|
|
409
394
|
},
|
|
410
395
|
form: {
|
|
411
396
|
selectors: ['form[aria-label]', 'form[aria-labelledby]', 'form[title]'],
|
|
412
397
|
},
|
|
413
|
-
generic: {
|
|
414
|
-
selectors: [
|
|
415
|
-
'body',
|
|
416
|
-
'div',
|
|
417
|
-
'form:not([aria-label]):not([aria-labelledby]):not([title])',
|
|
418
|
-
'hgroup',
|
|
419
|
-
'span',
|
|
420
|
-
],
|
|
421
|
-
},
|
|
422
398
|
grid: {
|
|
423
399
|
childRoles: ['treegrid'],
|
|
424
400
|
},
|
|
@@ -427,22 +403,22 @@ exports.roles = {
|
|
|
427
403
|
nameFromContents: true,
|
|
428
404
|
},
|
|
429
405
|
group: {
|
|
430
|
-
selectors: ['details', '
|
|
406
|
+
selectors: ['details', 'optgroup'],
|
|
431
407
|
childRoles: ['row', 'select', 'toolbar', 'graphics-object'],
|
|
432
408
|
},
|
|
433
409
|
heading: {
|
|
434
410
|
selectors: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
|
|
435
411
|
nameFromContents: true,
|
|
412
|
+
defaults: {
|
|
413
|
+
'level': 2,
|
|
414
|
+
},
|
|
436
415
|
},
|
|
437
416
|
img: {
|
|
438
417
|
selectors: ['img:not([alt=""])', 'graphics-symbol'],
|
|
439
418
|
childRoles: ['doc-cover'],
|
|
440
419
|
},
|
|
441
420
|
input: {
|
|
442
|
-
childRoles: ['checkbox', '
|
|
443
|
-
},
|
|
444
|
-
insertion: {
|
|
445
|
-
selectors: ['ins'],
|
|
421
|
+
childRoles: ['checkbox', 'option', 'radio', 'slider', 'spinbutton', 'textbox'],
|
|
446
422
|
},
|
|
447
423
|
landmark: {
|
|
448
424
|
childRoles: [
|
|
@@ -478,12 +454,11 @@ exports.roles = {
|
|
|
478
454
|
nameFromContents: true,
|
|
479
455
|
},
|
|
480
456
|
list: {
|
|
481
|
-
selectors: ['
|
|
457
|
+
selectors: ['dl', 'ol', 'ul'],
|
|
482
458
|
childRoles: ['directory', 'feed'],
|
|
483
459
|
},
|
|
484
460
|
listbox: {
|
|
485
461
|
selectors: [
|
|
486
|
-
'datalist',
|
|
487
462
|
'select[multiple]',
|
|
488
463
|
'select[size]:not([size="0"]):not([size="1"])',
|
|
489
464
|
],
|
|
@@ -492,8 +467,8 @@ exports.roles = {
|
|
|
492
467
|
},
|
|
493
468
|
},
|
|
494
469
|
listitem: {
|
|
495
|
-
selectors: ['
|
|
496
|
-
childRoles: ['treeitem'],
|
|
470
|
+
selectors: ['dt', 'ul > li', 'ol > li'],
|
|
471
|
+
childRoles: ['doc-biblioentry', 'doc-endnote', 'treeitem'],
|
|
497
472
|
},
|
|
498
473
|
log: {
|
|
499
474
|
defaults: {
|
|
@@ -506,14 +481,8 @@ exports.roles = {
|
|
|
506
481
|
math: {
|
|
507
482
|
selectors: ['math'],
|
|
508
483
|
},
|
|
509
|
-
meter: {
|
|
510
|
-
selectors: ['meter'],
|
|
511
|
-
defaults: {
|
|
512
|
-
'valuemin': 0,
|
|
513
|
-
'valuemax': 100,
|
|
514
|
-
},
|
|
515
|
-
},
|
|
516
484
|
menu: {
|
|
485
|
+
selectors: ['menu[type="context"]'],
|
|
517
486
|
childRoles: ['menubar'],
|
|
518
487
|
defaults: {
|
|
519
488
|
'orientation': 'vertical',
|
|
@@ -533,10 +502,16 @@ exports.roles = {
|
|
|
533
502
|
selectors: ['menuitem[type="checkbox"]'],
|
|
534
503
|
childRoles: ['menuitemradio'],
|
|
535
504
|
nameFromContents: true,
|
|
505
|
+
defaults: {
|
|
506
|
+
'checked': 'false',
|
|
507
|
+
},
|
|
536
508
|
},
|
|
537
509
|
menuitemradio: {
|
|
538
510
|
selectors: ['menuitem[type="radio"]'],
|
|
539
511
|
nameFromContents: true,
|
|
512
|
+
defaults: {
|
|
513
|
+
'checked': 'false',
|
|
514
|
+
},
|
|
540
515
|
},
|
|
541
516
|
navigation: {
|
|
542
517
|
selectors: ['nav'],
|
|
@@ -553,22 +528,19 @@ exports.roles = {
|
|
|
553
528
|
'selected': 'false',
|
|
554
529
|
},
|
|
555
530
|
},
|
|
556
|
-
paragraph: {
|
|
557
|
-
selectors: ['p'],
|
|
558
|
-
},
|
|
559
531
|
progressbar: {
|
|
560
532
|
selectors: ['progress'],
|
|
561
|
-
defaults: {
|
|
562
|
-
'valuemin': 0,
|
|
563
|
-
'valuemax': 100,
|
|
564
|
-
},
|
|
565
533
|
},
|
|
566
534
|
radio: {
|
|
567
535
|
selectors: ['input[type="radio"]'],
|
|
536
|
+
childRoles: ['menuitemradio'],
|
|
568
537
|
nameFromContents: true,
|
|
538
|
+
defaults: {
|
|
539
|
+
'checked': 'false',
|
|
540
|
+
},
|
|
569
541
|
},
|
|
570
542
|
range: {
|
|
571
|
-
childRoles: ['
|
|
543
|
+
childRoles: ['progressbar', 'scrollbar', 'slider', 'spinbutton'],
|
|
572
544
|
},
|
|
573
545
|
region: {
|
|
574
546
|
selectors: ['section[aria-label]', 'section[aria-labelledby]', 'section[title]'],
|
|
@@ -582,6 +554,7 @@ exports.roles = {
|
|
|
582
554
|
},
|
|
583
555
|
rowgroup: {
|
|
584
556
|
selectors: ['tbody', 'thead', 'tfoot'],
|
|
557
|
+
nameFromContents: true,
|
|
585
558
|
},
|
|
586
559
|
rowheader: {
|
|
587
560
|
selectors: ['th[scope="row"]'],
|
|
@@ -602,27 +575,19 @@ exports.roles = {
|
|
|
602
575
|
section: {
|
|
603
576
|
childRoles: [
|
|
604
577
|
'alert',
|
|
605
|
-
'blockquote',
|
|
606
|
-
'caption',
|
|
607
578
|
'cell',
|
|
608
|
-
'code',
|
|
609
579
|
'definition',
|
|
610
|
-
'deletion',
|
|
611
580
|
'doc-abstract',
|
|
612
581
|
'doc-colophon',
|
|
613
582
|
'doc-credit',
|
|
614
583
|
'doc-dedication',
|
|
615
584
|
'doc-epigraph',
|
|
585
|
+
'doc-example',
|
|
616
586
|
'doc-footnote',
|
|
617
|
-
'doc-pagefooter',
|
|
618
|
-
'doc-pageheader',
|
|
619
|
-
'doc-pullquote',
|
|
620
587
|
'doc-qna',
|
|
621
|
-
'emphasis',
|
|
622
588
|
'figure',
|
|
623
589
|
'group',
|
|
624
590
|
'img',
|
|
625
|
-
'insertion',
|
|
626
591
|
'landmark',
|
|
627
592
|
'list',
|
|
628
593
|
'listitem',
|
|
@@ -630,15 +595,10 @@ exports.roles = {
|
|
|
630
595
|
'marquee',
|
|
631
596
|
'math',
|
|
632
597
|
'note',
|
|
633
|
-
'paragraph',
|
|
634
598
|
'status',
|
|
635
|
-
'strong',
|
|
636
|
-
'subscript',
|
|
637
|
-
'superscript',
|
|
638
599
|
'table',
|
|
639
600
|
'tabpanel',
|
|
640
601
|
'term',
|
|
641
|
-
'time',
|
|
642
602
|
'tooltip',
|
|
643
603
|
],
|
|
644
604
|
},
|
|
@@ -653,7 +613,7 @@ exports.roles = {
|
|
|
653
613
|
nameFromContents: true,
|
|
654
614
|
},
|
|
655
615
|
select: {
|
|
656
|
-
childRoles: ['listbox', 'menu', 'radiogroup', 'tree'],
|
|
616
|
+
childRoles: ['combobox', 'listbox', 'menu', 'radiogroup', 'tree'],
|
|
657
617
|
},
|
|
658
618
|
separator: {
|
|
659
619
|
// assume not focussable because <hr> is not
|
|
@@ -676,7 +636,8 @@ exports.roles = {
|
|
|
676
636
|
spinbutton: {
|
|
677
637
|
selectors: ['input[type="number"]'],
|
|
678
638
|
defaults: {
|
|
679
|
-
// FIXME: no valuemin/valuemax
|
|
639
|
+
// FIXME: no valuemin/valuemax
|
|
640
|
+
'valuenow': 0,
|
|
680
641
|
},
|
|
681
642
|
},
|
|
682
643
|
status: {
|
|
@@ -687,31 +648,23 @@ exports.roles = {
|
|
|
687
648
|
'atomic': true,
|
|
688
649
|
},
|
|
689
650
|
},
|
|
690
|
-
strong: {
|
|
691
|
-
selectors: ['strong'],
|
|
692
|
-
},
|
|
693
651
|
structure: {
|
|
694
652
|
childRoles: [
|
|
695
653
|
'application',
|
|
696
654
|
'document',
|
|
697
655
|
'none',
|
|
698
|
-
'generic',
|
|
699
656
|
'presentation',
|
|
700
|
-
'range',
|
|
701
657
|
'rowgroup',
|
|
702
658
|
'section',
|
|
703
659
|
'sectionhead',
|
|
704
660
|
'separator',
|
|
705
661
|
],
|
|
706
662
|
},
|
|
707
|
-
subscript: {
|
|
708
|
-
selectors: ['sub'],
|
|
709
|
-
},
|
|
710
|
-
superscript: {
|
|
711
|
-
selectors: ['sup'],
|
|
712
|
-
},
|
|
713
663
|
switch: {
|
|
714
664
|
nameFromContents: true,
|
|
665
|
+
defaults: {
|
|
666
|
+
'checked': false,
|
|
667
|
+
},
|
|
715
668
|
},
|
|
716
669
|
tab: {
|
|
717
670
|
nameFromContents: true,
|
|
@@ -742,9 +695,6 @@ exports.roles = {
|
|
|
742
695
|
],
|
|
743
696
|
childRoles: ['searchbox'],
|
|
744
697
|
},
|
|
745
|
-
time: {
|
|
746
|
-
selectors: ['time'],
|
|
747
|
-
},
|
|
748
698
|
toolbar: {
|
|
749
699
|
defaults: {
|
|
750
700
|
'orientation': 'horizontal',
|
|
@@ -768,9 +718,8 @@ exports.roles = {
|
|
|
768
718
|
'composite',
|
|
769
719
|
'gridcell',
|
|
770
720
|
'input',
|
|
771
|
-
'
|
|
721
|
+
'range',
|
|
772
722
|
'row',
|
|
773
|
-
'scrollbar',
|
|
774
723
|
'tab',
|
|
775
724
|
],
|
|
776
725
|
},
|
|
@@ -831,17 +780,6 @@ exports.nameDefaults = {
|
|
|
831
780
|
'summary': 'Details',
|
|
832
781
|
};
|
|
833
782
|
|
|
834
|
-
exports.labelable = [
|
|
835
|
-
'button',
|
|
836
|
-
'input:not([type="hidden"])',
|
|
837
|
-
'keygen',
|
|
838
|
-
'meter',
|
|
839
|
-
'output',
|
|
840
|
-
'progress',
|
|
841
|
-
'select',
|
|
842
|
-
'textarea',
|
|
843
|
-
];
|
|
844
|
-
|
|
845
783
|
},{}],5:[function(require,module,exports){
|
|
846
784
|
var constants = require('./constants.js');
|
|
847
785
|
var atree = require('./atree.js');
|
|
@@ -894,14 +832,9 @@ var allowNameFromContent = function(el) {
|
|
|
894
832
|
return (constants.roles[role] || {}).nameFromContents;
|
|
895
833
|
};
|
|
896
834
|
|
|
897
|
-
var isLabelable = function(el) {
|
|
898
|
-
var selector = constants.labelable.join(',');
|
|
899
|
-
return el.matches(selector);
|
|
900
|
-
};
|
|
901
|
-
|
|
902
835
|
var isInLabelForOtherWidget = function(el) {
|
|
903
836
|
var label = el.parentElement.closest('label');
|
|
904
|
-
return label && !Array.prototype.includes.call(el.labels, label);
|
|
837
|
+
return label && (!el.label || !Array.prototype.includes.call(el.labels, label));
|
|
905
838
|
};
|
|
906
839
|
|
|
907
840
|
var getName = function(el, recursive, visited, directReference) {
|
|
@@ -936,7 +869,7 @@ var getName = function(el, recursive, visited, directReference) {
|
|
|
936
869
|
}
|
|
937
870
|
|
|
938
871
|
// D
|
|
939
|
-
if (!ret.trim() && !recursive &&
|
|
872
|
+
if (!ret.trim() && !recursive && el.labels) {
|
|
940
873
|
var strings = Array.prototype.map.call(el.labels, function(label) {
|
|
941
874
|
return getName(label, true, visited);
|
|
942
875
|
});
|
package/lib/atree.js
CHANGED
|
@@ -14,12 +14,12 @@ var _getParentNode = function(node) {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
var detectLoop = function(node) {
|
|
17
|
-
var
|
|
18
|
-
while (
|
|
19
|
-
if (
|
|
17
|
+
var seen = [node]
|
|
18
|
+
while ((node = _getParentNode(node))) {
|
|
19
|
+
if (seen.includes(node)) {
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
seen.push(node)
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
package/lib/attrs.js
CHANGED
|
@@ -50,6 +50,9 @@ var getAttribute = function(el, key) {
|
|
|
50
50
|
if (el.matches('noscript')) {
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
|
+
if (el.matches('details:not([open]) :not(summary)')) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
53
56
|
var style = window.getComputedStyle(el);
|
|
54
57
|
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
55
58
|
return true;
|
package/lib/constants.js
CHANGED
|
@@ -546,14 +546,3 @@ exports.nameDefaults = {
|
|
|
546
546
|
'input[type="reset"]': 'Reset',
|
|
547
547
|
'summary': 'Details',
|
|
548
548
|
};
|
|
549
|
-
|
|
550
|
-
exports.labelable = [
|
|
551
|
-
'button',
|
|
552
|
-
'input:not([type="hidden"])',
|
|
553
|
-
'keygen',
|
|
554
|
-
'meter',
|
|
555
|
-
'output',
|
|
556
|
-
'progress',
|
|
557
|
-
'select',
|
|
558
|
-
'textarea',
|
|
559
|
-
];
|
package/lib/name.js
CHANGED
|
@@ -49,14 +49,9 @@ var allowNameFromContent = function(el) {
|
|
|
49
49
|
return (constants.roles[role] || {}).nameFromContents;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
var isLabelable = function(el) {
|
|
53
|
-
var selector = constants.labelable.join(',');
|
|
54
|
-
return el.matches(selector);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
52
|
var isInLabelForOtherWidget = function(el) {
|
|
58
53
|
var label = el.parentElement.closest('label');
|
|
59
|
-
return label && !Array.prototype.includes.call(el.labels, label);
|
|
54
|
+
return label && (!el.label || !Array.prototype.includes.call(el.labels, label));
|
|
60
55
|
};
|
|
61
56
|
|
|
62
57
|
var getName = function(el, recursive, visited, directReference) {
|
|
@@ -91,7 +86,7 @@ var getName = function(el, recursive, visited, directReference) {
|
|
|
91
86
|
}
|
|
92
87
|
|
|
93
88
|
// D
|
|
94
|
-
if (!ret.trim() && !recursive &&
|
|
89
|
+
if (!ret.trim() && !recursive && el.labels) {
|
|
95
90
|
var strings = Array.prototype.map.call(el.labels, function(label) {
|
|
96
91
|
return getName(label, true, visited);
|
|
97
92
|
});
|