Skip to content

Commit 19bde94

Browse files
authoredMay 2, 2024
fix(aria-roles): correct abstract roles (types) for aria-roles (#4421)
Too many aria roles were set to widget or otherwise were incorrect, added a comment source for where I got my information for which abstract roles were the type of other aria roles Fix: #4371
2 parents 7ac6392 + 5594d8f commit 19bde94

File tree

8 files changed

+105
-12
lines changed

8 files changed

+105
-12
lines changed
 

‎doc/standards-object.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ The [`ariaRoles`](../lib/standards/aria-roles.js) object defines valid ARIA role
6767

6868
- `type` - string(required). [The role type](https://www.w3.org/TR/wai-aria-1.1/#roles_categorization). Valid types are:
6969
- `abstract`
70-
- `widget`
71-
- `structure`
70+
- `composite`
7271
- `landmark`
72+
- `structure`
73+
- `widget`
74+
- `window`
7375
- `requiredContext` - array(optional). List of required parent roles.
7476
- `requiredOwned` - array(optional). List of required owned roles.
7577
- `requiredAttrs` - array(optional). List of required attributes.

‎lib/checks/aria/valid-scrollable-semantics-evaluate.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ const VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS = {
1616
* appropriate for scrollable elements found in the focus order.
1717
*/
1818
const VALID_ROLES_FOR_SCROLLABLE_REGIONS = {
19+
alert: true,
20+
alertdialog: true,
1921
application: true,
2022
article: true,
2123
banner: false,
2224
complementary: true,
2325
contentinfo: true,
26+
dialog: true,
2427
form: true,
28+
log: true,
2529
main: true,
2630
navigation: true,
2731
region: true,
28-
search: false
32+
search: false,
33+
status: true
2934
};
3035

3136
/**

‎lib/standards/aria-roles.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Source: https://www.w3.org/TR/wai-aria-1.1/#roles
2+
// Source for abstract roles (types): https://www.w3.org/TR/wai-aria/#abstract_roles
23

34
/* easiest way to see allowed roles is to filter out the global ones
45
from the list of inherited states and properties. The dpub spec
@@ -17,13 +18,13 @@
1718
*/
1819
const ariaRoles = {
1920
alert: {
20-
type: 'widget',
21+
type: 'structure',
2122
// Spec difference: Aria-expanded removed in 1.2
2223
allowedAttrs: ['aria-expanded'],
2324
superclassRole: ['section']
2425
},
2526
alertdialog: {
26-
type: 'widget',
27+
type: 'window',
2728
// Spec difference: Aria-expanded removed in 1.2
2829
allowedAttrs: ['aria-expanded', 'aria-modal'],
2930
superclassRole: ['alert', 'dialog'],
@@ -119,6 +120,7 @@ const ariaRoles = {
119120
nameFromContent: true
120121
},
121122
combobox: {
123+
// Note: spec difference
122124
type: 'widget',
123125
requiredAttrs: ['aria-expanded', 'aria-controls'],
124126
allowedAttrs: [
@@ -169,7 +171,7 @@ const ariaRoles = {
169171
prohibitedAttrs: ['aria-label', 'aria-labelledby']
170172
},
171173
dialog: {
172-
type: 'widget',
174+
type: 'window',
173175
// Spec difference: Aria-expanded removed in 1.2
174176
allowedAttrs: ['aria-expanded', 'aria-modal'],
175177
superclassRole: ['window'],
@@ -301,6 +303,7 @@ const ariaRoles = {
301303
superclassRole: ['section']
302304
},
303305
listbox: {
306+
// Note: spec difference
304307
type: 'widget',
305308
requiredOwned: ['group', 'option'],
306309
allowedAttrs: [
@@ -328,7 +331,7 @@ const ariaRoles = {
328331
nameFromContent: true
329332
},
330333
log: {
331-
type: 'widget',
334+
type: 'structure',
332335
// Spec difference: Aria-expanded removed in 1.2
333336
allowedAttrs: ['aria-expanded'],
334337
superclassRole: ['section']
@@ -340,7 +343,7 @@ const ariaRoles = {
340343
superclassRole: ['landmark']
341344
},
342345
marquee: {
343-
type: 'widget',
346+
type: 'structure',
344347
// Spec difference: Aria-expanded removed in 1.2
345348
allowedAttrs: ['aria-expanded'],
346349
superclassRole: ['section']
@@ -696,7 +699,7 @@ const ariaRoles = {
696699
accessibleNameRequired: true
697700
},
698701
status: {
699-
type: 'widget',
702+
type: 'structure',
700703
// Spec difference: Aria-expanded removed in 1.2
701704
allowedAttrs: ['aria-expanded'],
702705
superclassRole: ['section']
@@ -816,7 +819,7 @@ const ariaRoles = {
816819
superclassRole: ['section']
817820
},
818821
timer: {
819-
type: 'widget',
822+
type: 'structure',
820823
// Spec difference: Aria-expanded removed in 1.2
821824
allowedAttrs: ['aria-expanded'],
822825
superclassRole: ['status']

‎test/checks/aria/valid-scrollable-semantics.js

+24
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ describe('valid-scrollable-semantics', function () {
106106
);
107107
});
108108

109+
it('should return true for role=alertdialog', function () {
110+
var node = document.createElement('div');
111+
node.setAttribute('role', 'alertdialog');
112+
fixture.appendChild(node);
113+
flatTreeSetup(fixture);
114+
assert.isTrue(
115+
axe.testUtils
116+
.getCheckEvaluate('valid-scrollable-semantics')
117+
.call(checkContext, node)
118+
);
119+
});
120+
109121
it('should return true for role=article', function () {
110122
var node = document.createElement('div');
111123
node.setAttribute('role', 'article');
@@ -118,6 +130,18 @@ describe('valid-scrollable-semantics', function () {
118130
);
119131
});
120132

133+
it('should return true for role=dialog', function () {
134+
var node = document.createElement('div');
135+
node.setAttribute('role', 'dialog');
136+
fixture.appendChild(node);
137+
flatTreeSetup(fixture);
138+
assert.isTrue(
139+
axe.testUtils
140+
.getCheckEvaluate('valid-scrollable-semantics')
141+
.call(checkContext, node)
142+
);
143+
});
144+
121145
it('should return true for nav elements', function () {
122146
var node = document.createElement('nav');
123147
fixture.appendChild(node);

‎test/integration/rules/focus-order-semantics/focus-order-semantics.html

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ <h4>Invalid landmark roles for scrollable containers</h4>
1919
<div>
2020
<div id="violation3" role="banner" tabindex="0"></div>
2121
<div id="violation4" role="search" tabindex="0"></div>
22+
<div id="violation5" role="marquee" tabindex="0"></div>
23+
<div id="violation6" role="timer" tabindex="0"></div>
2224
</div>
2325
<h4>Valid landmark roles for scrollable containers</h4>
2426
<div>
@@ -31,6 +33,14 @@ <h4>Valid landmark roles for scrollable containers</h4>
3133
<div id="pass8" role="application" tabindex="0"></div>
3234
<div id="pass9" role="tooltip" tabindex="0"></div>
3335
<div id="pass10" role="article" tabindex="0"></div>
36+
<div id="pass11" role="alert" tabindex="0"></div>
37+
<div id="pass12" role="log" tabindex="0"></div>
38+
<div id="pass13" role="status" tabindex="0"></div>
39+
</div>
40+
<h4>Valid window roles for scrollable containers</h4>
41+
<div>
42+
<div id="pass14" role="alertdialog" tabindex="0"></div>
43+
<div id="pass15" role="dialog" tabindex="0"></div>
3444
</div>
3545
<h4>
3646
Valid scrollable HTML tags for scrollable regions, not selected by this

‎test/integration/rules/focus-order-semantics/focus-order-semantics.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111
["#pass7"],
1212
["#pass8"],
1313
["#pass9"],
14-
["#pass10"]
14+
["#pass10"],
15+
["#pass11"],
16+
["#pass12"],
17+
["#pass13"],
18+
["#pass14"],
19+
["#pass15"]
1520
],
1621
"violations": [
1722
["#violation1"],
1823
["#violation2"],
1924
["#violation3"],
20-
["#violation4"]
25+
["#violation4"],
26+
["#violation5"],
27+
["#violation6"]
2128
]
2229
}

‎test/integration/rules/target-size/target-size.html

+35
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,41 @@
2828
</textarea>
2929
</p>
3030

31+
<div>
32+
<button id="pass9">x</button>
33+
<div role="alertdialog" tabindex="0" id="ignore1">Cookies</div>
34+
</div>
35+
36+
<div>
37+
<button id="pass10">x</button>
38+
<div role="dialog" tabindex="0" id="ignore2">Cookies</div>
39+
</div>
40+
41+
<div>
42+
<button id="pass11">x</button>
43+
<div role="alert" tabindex="0" id="ignore3">Cookies</div>
44+
</div>
45+
46+
<div>
47+
<button id="pass12">x</button>
48+
<div role="log" tabindex="0" id="ignore4">Log</div>
49+
</div>
50+
51+
<div>
52+
<button id="pass13">x</button>
53+
<div role="marquee" tabindex="0" id="ignore4">Marquee</div>
54+
</div>
55+
56+
<div>
57+
<button id="pass14">x</button>
58+
<div role="status" tabindex="0" id="ignore5">Status</div>
59+
</div>
60+
61+
<div>
62+
<button id="pass15">x</button>
63+
<div role="timer" tabindex="0" id="ignore6">Timer</div>
64+
</div>
65+
3166
<!-- Nested controls-->
3267
<p>
3368
<a

‎test/integration/rules/target-size/target-size.json

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
["#pass6"],
2121
["#pass7"],
2222
["#pass8"],
23+
["#pass9"],
24+
["#pass10"],
25+
["#pass11"],
26+
["#pass12"],
27+
["#pass13"],
28+
["#pass14"],
29+
["#pass15"],
2330
["#pass-adjacent"],
2431
["#pass-fixed"]
2532
],

0 commit comments

Comments
 (0)
Failed to load comments.