aria-api 0.4.1 → 0.4.3
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 +1 -1
- package/dist/aria.js +46 -51
- package/lib/atree.js +6 -6
- package/lib/attrs.js +3 -0
- package/lib/constants.js +37 -45
- package/package.json +1 -1
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/
|
|
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
|
}
|
|
@@ -35,18 +35,18 @@ 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
|
|
|
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
|
}
|
|
@@ -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;
|
|
@@ -228,62 +231,56 @@ module.exports = {
|
|
|
228
231
|
};
|
|
229
232
|
|
|
230
233
|
},{"./constants.js":4}],4:[function(require,module,exports){
|
|
234
|
+
// https://www.w3.org/TR/wai-aria/#state_prop_def
|
|
231
235
|
exports.attributes = {
|
|
232
|
-
|
|
236
|
+
'activedescendant': 'id',
|
|
237
|
+
'atomic': 'bool',
|
|
233
238
|
'autocomplete': 'token',
|
|
239
|
+
'busy': 'bool',
|
|
234
240
|
'checked': 'tristate',
|
|
241
|
+
'colcount': 'int',
|
|
242
|
+
'colindex': 'int',
|
|
243
|
+
'colspan': 'int',
|
|
244
|
+
'controls': 'id-list',
|
|
235
245
|
'current': 'token',
|
|
246
|
+
'describedby': 'id-list',
|
|
247
|
+
'details': 'id',
|
|
236
248
|
'disabled': 'bool',
|
|
249
|
+
'dropeffect': 'token-list',
|
|
250
|
+
'errormessage': 'id',
|
|
237
251
|
'expanded': 'bool-undefined',
|
|
252
|
+
'flowto': 'id-list',
|
|
253
|
+
'grabbed': 'bool-undefined',
|
|
238
254
|
'haspopup': 'token',
|
|
239
|
-
'hidden': 'bool',
|
|
255
|
+
'hidden': 'bool-undefined',
|
|
240
256
|
'invalid': 'token',
|
|
241
257
|
'keyshortcuts': 'string',
|
|
242
258
|
'label': 'string',
|
|
259
|
+
'labelledby': 'id-list',
|
|
243
260
|
'level': 'int',
|
|
261
|
+
'live': 'token',
|
|
244
262
|
'modal': 'bool',
|
|
245
263
|
'multiline': 'bool',
|
|
246
264
|
'multiselectable': 'bool',
|
|
247
265
|
'orientation': 'token',
|
|
266
|
+
'owns': 'id-list',
|
|
248
267
|
'placeholder': 'string',
|
|
268
|
+
'posinset': 'int',
|
|
249
269
|
'pressed': 'tristate',
|
|
250
270
|
'readonly': 'bool',
|
|
271
|
+
'relevant': 'token-list',
|
|
251
272
|
'required': 'bool',
|
|
252
273
|
'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
274
|
'rowcount': 'int',
|
|
283
275
|
'rowindex': 'int',
|
|
284
276
|
'rowspan': 'int',
|
|
277
|
+
'selected': 'bool-undefined',
|
|
285
278
|
'setsize': 'int',
|
|
286
279
|
'sort': 'token',
|
|
280
|
+
'valuemax': 'number',
|
|
281
|
+
'valuemin': 'number',
|
|
282
|
+
'valuenow': 'number',
|
|
283
|
+
'valuetext': 'string',
|
|
287
284
|
};
|
|
288
285
|
|
|
289
286
|
exports.attributeStrongMapping = {
|
|
@@ -329,6 +326,7 @@ exports.roles = {
|
|
|
329
326
|
cell: {
|
|
330
327
|
selectors: ['td'],
|
|
331
328
|
childRoles: ['gridcell', 'rowheader'],
|
|
329
|
+
nameFromContents: true,
|
|
332
330
|
},
|
|
333
331
|
checkbox: {
|
|
334
332
|
selectors: ['input[type="checkbox"]'],
|
|
@@ -554,14 +552,14 @@ exports.roles = {
|
|
|
554
552
|
selectors: ['tr'],
|
|
555
553
|
nameFromContents: true,
|
|
556
554
|
},
|
|
557
|
-
rowheader: {
|
|
558
|
-
selectors: ['th[scope="row"]'],
|
|
559
|
-
nameFromContents: true,
|
|
560
|
-
},
|
|
561
555
|
rowgroup: {
|
|
562
556
|
selectors: ['tbody', 'thead', 'tfoot'],
|
|
563
557
|
nameFromContents: true,
|
|
564
558
|
},
|
|
559
|
+
rowheader: {
|
|
560
|
+
selectors: ['th[scope="row"]'],
|
|
561
|
+
nameFromContents: true,
|
|
562
|
+
},
|
|
565
563
|
scrollbar: {
|
|
566
564
|
defaults: {
|
|
567
565
|
'orientation': 'vertical',
|
|
@@ -618,13 +616,11 @@ exports.roles = {
|
|
|
618
616
|
childRoles: ['combobox', 'listbox', 'menu', 'radiogroup', 'tree'],
|
|
619
617
|
},
|
|
620
618
|
separator: {
|
|
619
|
+
// assume not focussable because <hr> is not
|
|
621
620
|
selectors: ['hr'],
|
|
622
621
|
childRoles: ['doc-pagebreak'],
|
|
623
622
|
defaults: {
|
|
624
623
|
'orientation': 'horizontal',
|
|
625
|
-
'valuemin': 0,
|
|
626
|
-
'valuemax': 100,
|
|
627
|
-
'valuenow': 50,
|
|
628
624
|
},
|
|
629
625
|
},
|
|
630
626
|
slider: {
|
|
@@ -652,12 +648,6 @@ exports.roles = {
|
|
|
652
648
|
'atomic': true,
|
|
653
649
|
},
|
|
654
650
|
},
|
|
655
|
-
switch: {
|
|
656
|
-
nameFromContents: true,
|
|
657
|
-
defaults: {
|
|
658
|
-
'checked': false,
|
|
659
|
-
},
|
|
660
|
-
},
|
|
661
651
|
structure: {
|
|
662
652
|
childRoles: [
|
|
663
653
|
'application',
|
|
@@ -670,6 +660,12 @@ exports.roles = {
|
|
|
670
660
|
'separator',
|
|
671
661
|
],
|
|
672
662
|
},
|
|
663
|
+
switch: {
|
|
664
|
+
nameFromContents: true,
|
|
665
|
+
defaults: {
|
|
666
|
+
'checked': false,
|
|
667
|
+
},
|
|
668
|
+
},
|
|
673
669
|
tab: {
|
|
674
670
|
nameFromContents: true,
|
|
675
671
|
defaults: {
|
|
@@ -724,7 +720,6 @@ exports.roles = {
|
|
|
724
720
|
'input',
|
|
725
721
|
'range',
|
|
726
722
|
'row',
|
|
727
|
-
'separator',
|
|
728
723
|
'tab',
|
|
729
724
|
],
|
|
730
725
|
},
|
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
|
}
|
|
@@ -14,18 +14,18 @@ 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
|
|
|
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/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
|
@@ -1,59 +1,53 @@
|
|
|
1
|
+
// https://www.w3.org/TR/wai-aria/#state_prop_def
|
|
1
2
|
exports.attributes = {
|
|
2
|
-
|
|
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
|
},
|