@selenium/atoms 4.52.0 → 4.53.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/README.md +56 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/typescript/accessibility-snapshot-wire.d.ts +4 -0
- package/dist/typescript/accessibility-snapshot-wire.d.ts.map +1 -0
- package/dist/typescript/accessibility-snapshot-wire.js +18 -0
- package/dist/typescript/accessibility-snapshot-wire.js.map +1 -0
- package/dist/typescript/accessibility-snapshot.d.ts +3 -0
- package/dist/typescript/accessibility-snapshot.d.ts.map +1 -0
- package/dist/typescript/accessibility-snapshot.js +18 -0
- package/dist/typescript/accessibility-snapshot.js.map +1 -0
- package/dist/typescript/core/accessibility/accname.d.ts +6 -0
- package/dist/typescript/core/accessibility/accname.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/accname.js +537 -0
- package/dist/typescript/core/accessibility/accname.js.map +1 -0
- package/dist/typescript/core/accessibility/context.d.ts +43 -0
- package/dist/typescript/core/accessibility/context.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/context.js +49 -0
- package/dist/typescript/core/accessibility/context.js.map +1 -0
- package/dist/typescript/core/accessibility/hidden.d.ts +39 -0
- package/dist/typescript/core/accessibility/hidden.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/hidden.js +216 -0
- package/dist/typescript/core/accessibility/hidden.js.map +1 -0
- package/dist/typescript/core/accessibility/roles.d.ts +28 -0
- package/dist/typescript/core/accessibility/roles.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/roles.js +381 -0
- package/dist/typescript/core/accessibility/roles.js.map +1 -0
- package/dist/typescript/core/accessibility/snapshot.d.ts +13 -0
- package/dist/typescript/core/accessibility/snapshot.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/snapshot.js +55 -0
- package/dist/typescript/core/accessibility/snapshot.js.map +1 -0
- package/dist/typescript/core/accessibility/states.d.ts +18 -0
- package/dist/typescript/core/accessibility/states.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/states.js +215 -0
- package/dist/typescript/core/accessibility/states.js.map +1 -0
- package/dist/typescript/core/accessibility/tree.d.ts +10 -0
- package/dist/typescript/core/accessibility/tree.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/tree.js +261 -0
- package/dist/typescript/core/accessibility/tree.js.map +1 -0
- package/dist/typescript/core/accessibility/types.d.ts +30 -0
- package/dist/typescript/core/accessibility/types.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/types.js +18 -0
- package/dist/typescript/core/accessibility/types.js.map +1 -0
- package/dist/typescript/core/accessibility/value.d.ts +4 -0
- package/dist/typescript/core/accessibility/value.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/value.js +83 -0
- package/dist/typescript/core/accessibility/value.js.map +1 -0
- package/dist/typescript/core/accessibility/wire.d.ts +57 -0
- package/dist/typescript/core/accessibility/wire.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/wire.js +72 -0
- package/dist/typescript/core/accessibility/wire.js.map +1 -0
- package/index.ts +4 -0
- package/package.json +15 -1
- package/typescript/accessibility-snapshot-wire.ts +20 -0
- package/typescript/accessibility-snapshot.ts +21 -0
- package/typescript/core/accessibility/accname.ts +587 -0
- package/typescript/core/accessibility/context.ts +116 -0
- package/typescript/core/accessibility/hidden.ts +242 -0
- package/typescript/core/accessibility/roles.ts +410 -0
- package/typescript/core/accessibility/snapshot.ts +61 -0
- package/typescript/core/accessibility/states.ts +233 -0
- package/typescript/core/accessibility/tree.ts +306 -0
- package/typescript/core/accessibility/types.ts +52 -0
- package/typescript/core/accessibility/value.ts +89 -0
- package/typescript/core/accessibility/wire.ts +123 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
// Role computation: the explicit role attribute with the WAI-ARIA 1.2 fallback
|
|
18
|
+
// and conflict rules, then the html-aam implicit mapping. Where html-aam says
|
|
19
|
+
// an element has "no corresponding role" this reports `generic`, so the
|
|
20
|
+
// pruning rule in ADR 18205 treats it like a div. Two rows deliberately
|
|
21
|
+
// diverge from html-aam towards what engines expose, and the roles test page
|
|
22
|
+
// pins them: input type=password is a textbox and summary is a button.
|
|
23
|
+
// WAI-ARIA 1.2 roles authors may use (abstract roles left out), plus the
|
|
24
|
+
// graphics module roles that svg maps to.
|
|
25
|
+
const CONCRETE_ROLES = new Set([
|
|
26
|
+
'alert', 'alertdialog', 'application', 'article', 'banner', 'blockquote', 'button',
|
|
27
|
+
'caption', 'cell', 'checkbox', 'code', 'columnheader', 'combobox', 'complementary',
|
|
28
|
+
'contentinfo', 'definition', 'deletion', 'dialog', 'directory', 'document', 'emphasis',
|
|
29
|
+
'feed', 'figure', 'form', 'generic', 'grid', 'gridcell', 'group', 'heading', 'img',
|
|
30
|
+
'insertion', 'link', 'list', 'listbox', 'listitem', 'log', 'main', 'marquee', 'math',
|
|
31
|
+
'menu', 'menubar', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'meter',
|
|
32
|
+
'navigation', 'none', 'note', 'option', 'paragraph', 'presentation', 'progressbar',
|
|
33
|
+
'radio', 'radiogroup', 'region', 'row', 'rowgroup', 'rowheader', 'scrollbar', 'search',
|
|
34
|
+
'searchbox', 'separator', 'slider', 'spinbutton', 'status', 'strong', 'subscript',
|
|
35
|
+
'superscript', 'switch', 'tab', 'table', 'tablist', 'tabpanel', 'term', 'textbox', 'time',
|
|
36
|
+
'timer', 'toolbar', 'tooltip', 'tree', 'treegrid', 'treeitem',
|
|
37
|
+
'graphics-document', 'graphics-object', 'graphics-symbol',
|
|
38
|
+
]);
|
|
39
|
+
// WAI-ARIA 1.2 §6.4, global states and properties, including the four the
|
|
40
|
+
// spec deprecates as globals but still lists. Their presence stops
|
|
41
|
+
// none/presentation from applying (§9.1).
|
|
42
|
+
const GLOBAL_ARIA_ATTRIBUTES = [
|
|
43
|
+
'aria-atomic', 'aria-busy', 'aria-controls', 'aria-current', 'aria-describedby',
|
|
44
|
+
'aria-description', 'aria-details', 'aria-disabled', 'aria-dropeffect', 'aria-errormessage',
|
|
45
|
+
'aria-flowto', 'aria-grabbed', 'aria-haspopup', 'aria-hidden', 'aria-invalid',
|
|
46
|
+
'aria-keyshortcuts', 'aria-label', 'aria-labelledby', 'aria-live', 'aria-owns',
|
|
47
|
+
'aria-relevant', 'aria-roledescription',
|
|
48
|
+
];
|
|
49
|
+
// Elements that take focus on their own, when not disabled.
|
|
50
|
+
const NATIVELY_FOCUSABLE = new Set(['button', 'iframe', 'input', 'select', 'summary', 'textarea']);
|
|
51
|
+
// Not a WAI-ARIA role: the token ADR 18205 uses for frame leaves, which the
|
|
52
|
+
// bindings replace with the child document's tree.
|
|
53
|
+
const FRAME_ELEMENTS = new Set(['frame', 'iframe']);
|
|
54
|
+
const SECTIONING_CONTENT = new Set(['article', 'aside', 'nav', 'section']);
|
|
55
|
+
// html-aam: a header or footer is a landmark only outside these elements and
|
|
56
|
+
// outside elements with these roles.
|
|
57
|
+
const HEADER_FOOTER_SCOPES = new Set(['article', 'aside', 'main', 'nav', 'section']);
|
|
58
|
+
const HEADER_FOOTER_SCOPE_ROLES = new Set(['article', 'complementary', 'main', 'navigation', 'region']);
|
|
59
|
+
const LIST_PARENTS = new Set(['menu', 'ol', 'ul']);
|
|
60
|
+
export function isPresentational(role) {
|
|
61
|
+
return role === 'none' || role === 'presentation';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The first token of the role attribute that names a role authors may use,
|
|
65
|
+
* or null when there is none. Tokens match ASCII case-insensitively, which is
|
|
66
|
+
* what engines do.
|
|
67
|
+
*/
|
|
68
|
+
export function explicitRole(element) {
|
|
69
|
+
const attribute = element.getAttribute('role');
|
|
70
|
+
if (!attribute) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
for (const token of attribute.trim().toLowerCase().split(/\s+/)) {
|
|
74
|
+
if (CONCRETE_ROLES.has(token)) {
|
|
75
|
+
return token;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function hasGlobalAriaAttribute(element) {
|
|
81
|
+
return GLOBAL_ARIA_ATTRIBUTES.some((name) => element.hasAttribute(name));
|
|
82
|
+
}
|
|
83
|
+
// "Focusable" in the §9.1 sense: the element can take focus at all, including
|
|
84
|
+
// through a negative tabindex. This is narrower than core/focusable.ts, which
|
|
85
|
+
// answers WebDriver's question and counts every anchor and label. The states
|
|
86
|
+
// module uses the same notion for what an ancestor's aria-disabled reaches.
|
|
87
|
+
export function canTakeFocus(element) {
|
|
88
|
+
const name = element.localName;
|
|
89
|
+
if (NATIVELY_FOCUSABLE.has(name)) {
|
|
90
|
+
// A disabled control or a hidden input cannot take focus, whatever its tabindex.
|
|
91
|
+
if (name === 'input' && element.type === 'hidden') {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return !('disabled' in element && element.disabled);
|
|
95
|
+
}
|
|
96
|
+
const tabindex = element.getAttribute('tabindex');
|
|
97
|
+
if (tabindex !== null && /^\s*[-+]?\d+\s*$/.test(tabindex)) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
if (name === 'a' || name === 'area') {
|
|
101
|
+
return element.hasAttribute('href');
|
|
102
|
+
}
|
|
103
|
+
return element.isContentEditable === true;
|
|
104
|
+
}
|
|
105
|
+
// html-aam makes some roles depend on whether the element has an accessible
|
|
106
|
+
// name (section, form, aside inside sectioning content). Only the author
|
|
107
|
+
// sources that can produce one are checked here: aria-label, an
|
|
108
|
+
// aria-labelledby that resolves to something with a text alternative, or a
|
|
109
|
+
// title. The full name computation is not what those rows ask for.
|
|
110
|
+
function hasAuthorName(element) {
|
|
111
|
+
const label = element.getAttribute('aria-label');
|
|
112
|
+
if (label !== null && label.trim() !== '') {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
const labelledBy = element.getAttribute('aria-labelledby');
|
|
116
|
+
if (labelledBy !== null && labelledBy.trim() !== '') {
|
|
117
|
+
const root = element.getRootNode();
|
|
118
|
+
for (const id of labelledBy.trim().split(/\s+/)) {
|
|
119
|
+
const target = root.getElementById(id);
|
|
120
|
+
if (target && hasTextAlternative(target)) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const title = element.getAttribute('title');
|
|
126
|
+
return title !== null && title.trim() !== '';
|
|
127
|
+
}
|
|
128
|
+
// The attributes accname reads for the text alternative of an element inside
|
|
129
|
+
// a referenced label when it has no text of its own: an image's alt, a label
|
|
130
|
+
// or tooltip, a control's value.
|
|
131
|
+
const ALTERNATIVE_ATTRIBUTES = ['aria-label', 'alt', 'title', 'value'];
|
|
132
|
+
// Whether a referenced label can contribute any text: its own text content,
|
|
133
|
+
// or an alternative on it or on an element below it.
|
|
134
|
+
function hasTextAlternative(target) {
|
|
135
|
+
if ((target.textContent || '').trim() !== '') {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
const elements = [target, ...Array.from(target.querySelectorAll('*'))];
|
|
139
|
+
return elements.some((candidate) => ALTERNATIVE_ATTRIBUTES.some((attribute) => (candidate.getAttribute(attribute) || '').trim() !== ''));
|
|
140
|
+
}
|
|
141
|
+
// WAI-ARIA 1.2 §9.1: when an element with required owned elements is
|
|
142
|
+
// presentational, so are those owned elements.
|
|
143
|
+
function ownerIsPresentational(owner, lookup) {
|
|
144
|
+
return owner !== null && isPresentational(lookup(owner));
|
|
145
|
+
}
|
|
146
|
+
function hasAncestor(element, names, roles = null) {
|
|
147
|
+
for (let parent = element.parentElement; parent; parent = parent.parentElement) {
|
|
148
|
+
if (names.has(parent.localName)) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (roles !== null) {
|
|
152
|
+
const role = explicitRole(parent);
|
|
153
|
+
if (role !== null && roles.has(role)) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
function inputRole(input) {
|
|
161
|
+
// The IDL property already folds unknown and missing types to "text".
|
|
162
|
+
const type = input.type;
|
|
163
|
+
const hasList = input.hasAttribute('list');
|
|
164
|
+
switch (type) {
|
|
165
|
+
case 'button':
|
|
166
|
+
case 'image':
|
|
167
|
+
case 'reset':
|
|
168
|
+
case 'submit':
|
|
169
|
+
return 'button';
|
|
170
|
+
case 'checkbox':
|
|
171
|
+
return 'checkbox';
|
|
172
|
+
case 'radio':
|
|
173
|
+
return 'radio';
|
|
174
|
+
case 'range':
|
|
175
|
+
return 'slider';
|
|
176
|
+
case 'number':
|
|
177
|
+
return 'spinbutton';
|
|
178
|
+
case 'search':
|
|
179
|
+
return hasList ? 'combobox' : 'searchbox';
|
|
180
|
+
case 'email':
|
|
181
|
+
case 'tel':
|
|
182
|
+
case 'text':
|
|
183
|
+
case 'url':
|
|
184
|
+
return hasList ? 'combobox' : 'textbox';
|
|
185
|
+
case 'password':
|
|
186
|
+
// html-aam: no corresponding role. Engines expose a textbox, and
|
|
187
|
+
// dropping password fields from the tree would hide a control users act on.
|
|
188
|
+
return 'textbox';
|
|
189
|
+
default:
|
|
190
|
+
// color, date, datetime-local, file, hidden, month, time, week.
|
|
191
|
+
return 'generic';
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function tableCellRole(cell, lookup) {
|
|
195
|
+
const table = cell.closest('table');
|
|
196
|
+
if (!table) {
|
|
197
|
+
return 'cell';
|
|
198
|
+
}
|
|
199
|
+
const tableRole = lookup(table);
|
|
200
|
+
if (isPresentational(tableRole)) {
|
|
201
|
+
return 'generic';
|
|
202
|
+
}
|
|
203
|
+
return tableRole === 'grid' || tableRole === 'treegrid' ? 'gridcell' : 'cell';
|
|
204
|
+
}
|
|
205
|
+
function tableHeaderRole(header, lookup) {
|
|
206
|
+
if (ownerIsPresentational(header.closest('table'), lookup)) {
|
|
207
|
+
return 'generic';
|
|
208
|
+
}
|
|
209
|
+
const scope = (header.getAttribute('scope') || '').toLowerCase();
|
|
210
|
+
return scope === 'row' || scope === 'rowgroup' ? 'rowheader' : 'columnheader';
|
|
211
|
+
}
|
|
212
|
+
function tablePartRole(part, role, lookup) {
|
|
213
|
+
return ownerIsPresentational(part.closest('table'), lookup) ? 'generic' : role;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The html-aam implicit role of an element, with no regard to its role
|
|
217
|
+
* attribute. `lookup` finds the role of an element this one depends on.
|
|
218
|
+
*/
|
|
219
|
+
export function implicitRole(element, lookup = computeRole) {
|
|
220
|
+
switch (element.localName) {
|
|
221
|
+
case 'a':
|
|
222
|
+
case 'area':
|
|
223
|
+
return element.hasAttribute('href') ? 'link' : 'generic';
|
|
224
|
+
case 'address':
|
|
225
|
+
case 'details':
|
|
226
|
+
case 'fieldset':
|
|
227
|
+
case 'hgroup':
|
|
228
|
+
case 'optgroup':
|
|
229
|
+
return 'group';
|
|
230
|
+
case 'article':
|
|
231
|
+
return 'article';
|
|
232
|
+
case 'aside':
|
|
233
|
+
if (!hasAncestor(element, SECTIONING_CONTENT)) {
|
|
234
|
+
return 'complementary';
|
|
235
|
+
}
|
|
236
|
+
return hasAuthorName(element) ? 'complementary' : 'generic';
|
|
237
|
+
case 'blockquote':
|
|
238
|
+
return 'blockquote';
|
|
239
|
+
case 'button':
|
|
240
|
+
return 'button';
|
|
241
|
+
case 'caption':
|
|
242
|
+
return 'caption';
|
|
243
|
+
case 'code':
|
|
244
|
+
return 'code';
|
|
245
|
+
case 'datalist':
|
|
246
|
+
return 'listbox';
|
|
247
|
+
case 'dd':
|
|
248
|
+
return 'definition';
|
|
249
|
+
case 'del':
|
|
250
|
+
return 'deletion';
|
|
251
|
+
case 'dfn':
|
|
252
|
+
case 'dt':
|
|
253
|
+
return 'term';
|
|
254
|
+
case 'dialog':
|
|
255
|
+
return 'dialog';
|
|
256
|
+
case 'em':
|
|
257
|
+
return 'emphasis';
|
|
258
|
+
case 'figure':
|
|
259
|
+
return 'figure';
|
|
260
|
+
case 'footer':
|
|
261
|
+
return hasAncestor(element, HEADER_FOOTER_SCOPES, HEADER_FOOTER_SCOPE_ROLES) ? 'generic' : 'contentinfo';
|
|
262
|
+
case 'form':
|
|
263
|
+
// html-aam: a landmark only with an accessible name, otherwise no role.
|
|
264
|
+
return hasAuthorName(element) ? 'form' : 'generic';
|
|
265
|
+
case 'frame':
|
|
266
|
+
case 'iframe':
|
|
267
|
+
return 'iframe';
|
|
268
|
+
case 'h1':
|
|
269
|
+
case 'h2':
|
|
270
|
+
case 'h3':
|
|
271
|
+
case 'h4':
|
|
272
|
+
case 'h5':
|
|
273
|
+
case 'h6':
|
|
274
|
+
return 'heading';
|
|
275
|
+
case 'header':
|
|
276
|
+
return hasAncestor(element, HEADER_FOOTER_SCOPES, HEADER_FOOTER_SCOPE_ROLES) ? 'generic' : 'banner';
|
|
277
|
+
case 'hr':
|
|
278
|
+
return 'separator';
|
|
279
|
+
case 'html':
|
|
280
|
+
return 'document';
|
|
281
|
+
case 'img':
|
|
282
|
+
if (element.getAttribute('alt') === '' && !hasGlobalAriaAttribute(element) && !canTakeFocus(element)) {
|
|
283
|
+
return 'presentation';
|
|
284
|
+
}
|
|
285
|
+
return 'img';
|
|
286
|
+
case 'input':
|
|
287
|
+
return inputRole(element);
|
|
288
|
+
case 'ins':
|
|
289
|
+
return 'insertion';
|
|
290
|
+
case 'li': {
|
|
291
|
+
const parent = element.parentElement;
|
|
292
|
+
if (!parent || !LIST_PARENTS.has(parent.localName) || ownerIsPresentational(parent, lookup)) {
|
|
293
|
+
return 'generic';
|
|
294
|
+
}
|
|
295
|
+
return 'listitem';
|
|
296
|
+
}
|
|
297
|
+
case 'main':
|
|
298
|
+
return 'main';
|
|
299
|
+
case 'math':
|
|
300
|
+
return 'math';
|
|
301
|
+
case 'menu':
|
|
302
|
+
case 'ol':
|
|
303
|
+
case 'ul':
|
|
304
|
+
return 'list';
|
|
305
|
+
case 'meter':
|
|
306
|
+
return 'meter';
|
|
307
|
+
case 'nav':
|
|
308
|
+
return 'navigation';
|
|
309
|
+
case 'option':
|
|
310
|
+
return 'option';
|
|
311
|
+
case 'output':
|
|
312
|
+
return 'status';
|
|
313
|
+
case 'p':
|
|
314
|
+
return 'paragraph';
|
|
315
|
+
case 'progress':
|
|
316
|
+
return 'progressbar';
|
|
317
|
+
case 'search':
|
|
318
|
+
return 'search';
|
|
319
|
+
case 'section':
|
|
320
|
+
return hasAuthorName(element) ? 'region' : 'generic';
|
|
321
|
+
case 'select': {
|
|
322
|
+
const select = element;
|
|
323
|
+
return select.multiple || select.size > 1 ? 'listbox' : 'combobox';
|
|
324
|
+
}
|
|
325
|
+
case 'strong':
|
|
326
|
+
return 'strong';
|
|
327
|
+
case 'sub':
|
|
328
|
+
return 'subscript';
|
|
329
|
+
case 'summary':
|
|
330
|
+
// html-aam: no corresponding role. Engines expose the disclosure control
|
|
331
|
+
// as a button, and that is what users click.
|
|
332
|
+
return 'button';
|
|
333
|
+
case 'sup':
|
|
334
|
+
return 'superscript';
|
|
335
|
+
case 'svg':
|
|
336
|
+
return 'graphics-document';
|
|
337
|
+
case 'table':
|
|
338
|
+
return 'table';
|
|
339
|
+
case 'tbody':
|
|
340
|
+
case 'tfoot':
|
|
341
|
+
case 'thead':
|
|
342
|
+
return tablePartRole(element, 'rowgroup', lookup);
|
|
343
|
+
case 'td':
|
|
344
|
+
return tableCellRole(element, lookup);
|
|
345
|
+
case 'textarea':
|
|
346
|
+
return 'textbox';
|
|
347
|
+
case 'th':
|
|
348
|
+
return tableHeaderRole(element, lookup);
|
|
349
|
+
case 'time':
|
|
350
|
+
return 'time';
|
|
351
|
+
case 'tr':
|
|
352
|
+
return tablePartRole(element, 'row', lookup);
|
|
353
|
+
default:
|
|
354
|
+
return 'generic';
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* The role the snapshot reports for an element: the explicit role when it
|
|
359
|
+
* names a usable role and is not a presentational role on an element that
|
|
360
|
+
* cannot be presentational (WAI-ARIA 1.2 §9.1), otherwise the implicit one.
|
|
361
|
+
* `lookup` finds the role of an element this one depends on; without one,
|
|
362
|
+
* it is computed afresh.
|
|
363
|
+
*/
|
|
364
|
+
export function computeRole(element, lookup = computeRole) {
|
|
365
|
+
if (FRAME_ELEMENTS.has(element.localName)) {
|
|
366
|
+
// The token is how the bindings find the frames whose documents they
|
|
367
|
+
// stitch in, so an explicit role (ARIA in HTML allows application,
|
|
368
|
+
// document, img and the presentational pair) never replaces it; the
|
|
369
|
+
// embedded document is exposed whatever the frame element is called.
|
|
370
|
+
return 'iframe';
|
|
371
|
+
}
|
|
372
|
+
const explicit = explicitRole(element);
|
|
373
|
+
if (explicit === null) {
|
|
374
|
+
return implicitRole(element, lookup);
|
|
375
|
+
}
|
|
376
|
+
if (isPresentational(explicit) && (canTakeFocus(element) || hasGlobalAriaAttribute(element))) {
|
|
377
|
+
return implicitRole(element, lookup);
|
|
378
|
+
}
|
|
379
|
+
return explicit;
|
|
380
|
+
}
|
|
381
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.js","sourceRoot":"","sources":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,IAAI;YACP,OAAO,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QAC9C;YACE,OAAO,SAAS,CAAA;IACpB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB,EAAE,SAAqB,WAAW;IAC5E,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1C,qEAAqE;QACrE,mEAAmE;QACnE,oEAAoE;QACpE,qEAAqE;QACrE,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IACtC,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACtC,CAAC;IACD,IAAI,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAC7F,OAAO,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACtC,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AccessibilityNode, SnapshotOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Computes an accessibility snapshot of the subtree rooted at `root`, or of the
|
|
4
|
+
* whole document when no root is given.
|
|
5
|
+
*
|
|
6
|
+
* The output is *computed* by script, not read from the browser's own
|
|
7
|
+
* accessibility tree. Frames are reported as `iframe` leaves and never
|
|
8
|
+
* descended into; callers stitch child-document snapshots in themselves.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
declare function accessibilitySnapshot(root?: Element | Document | null, options?: SnapshotOptions): AccessibilityNode;
|
|
12
|
+
export default accessibilitySnapshot;
|
|
13
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../../typescript/core/accessibility/snapshot.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA2BpE;;;;;;;;GAQG;AACH,iBAAS,qBAAqB,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,iBAAiB,CAE7G;AAED,eAAe,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
import { isElement } from '../element.js';
|
|
18
|
+
import { createContext } from './context.js';
|
|
19
|
+
import { buildTree } from './tree.js';
|
|
20
|
+
const DOCUMENT_NODE = 9;
|
|
21
|
+
function isDocument(node) {
|
|
22
|
+
return !!node && typeof node === 'object' && node.nodeType === DOCUMENT_NODE;
|
|
23
|
+
}
|
|
24
|
+
// A root that is not attached cannot answer "hidden" or "focused" questions, and
|
|
25
|
+
// a non-element root has no tree to walk, so both are refused up front rather
|
|
26
|
+
// than producing a partial snapshot the caller cannot distinguish from a real one.
|
|
27
|
+
function resolveRoot(root) {
|
|
28
|
+
if (root === undefined || root === null) {
|
|
29
|
+
return document.documentElement;
|
|
30
|
+
}
|
|
31
|
+
if (isDocument(root)) {
|
|
32
|
+
return root.documentElement;
|
|
33
|
+
}
|
|
34
|
+
if (!isElement(root)) {
|
|
35
|
+
throw new Error('accessibilitySnapshot: root must be an Element or a Document');
|
|
36
|
+
}
|
|
37
|
+
if (!root.isConnected) {
|
|
38
|
+
throw new Error('accessibilitySnapshot: root is detached from its document');
|
|
39
|
+
}
|
|
40
|
+
return root;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Computes an accessibility snapshot of the subtree rooted at `root`, or of the
|
|
44
|
+
* whole document when no root is given.
|
|
45
|
+
*
|
|
46
|
+
* The output is *computed* by script, not read from the browser's own
|
|
47
|
+
* accessibility tree. Frames are reported as `iframe` leaves and never
|
|
48
|
+
* descended into; callers stitch child-document snapshots in themselves.
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
function accessibilitySnapshot(root, options) {
|
|
52
|
+
return buildTree(resolveRoot(root), createContext(options));
|
|
53
|
+
}
|
|
54
|
+
export default accessibilitySnapshot;
|
|
55
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../../typescript/core/accessibility/snapshot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,wDAAwD;AACxD,6DAA6D;AAC7D,oDAAoD;AACpD,6DAA6D;AAC7D,6DAA6D;AAC7D,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,6DAA6D;AAC7D,8DAA8D;AAC9D,yDAAyD;AACzD,4DAA4D;AAC5D,0DAA0D;AAC1D,qBAAqB;AAErB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,MAAM,aAAa,GAAG,CAAC,CAAA;AAEvB,SAAS,UAAU,CAAC,IAAa;IAC/B,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAK,IAAa,CAAC,QAAQ,KAAK,aAAa,CAAA;AACxF,CAAC;AAED,iFAAiF;AACjF,8EAA8E;AAC9E,mFAAmF;AACnF,SAAS,WAAW,CAAC,IAA2C;IAC9D,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC,eAAe,CAAA;IACjC,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC,eAAe,CAAA;IAC7B,CAAC;IACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAA;IACjF,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAA;IAC9E,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,qBAAqB,CAAC,IAAgC,EAAE,OAAyB;IACxF,OAAO,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAA;AAC7D,CAAC;AAED,eAAe,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StateValue } from './types.js';
|
|
2
|
+
/** Whether the element itself sets aria-disabled=true. */
|
|
3
|
+
export declare function setsAriaDisabled(element: Element): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Whether an ancestor sets aria-disabled. The walk threads that down, so
|
|
6
|
+
* this check is only for a root or an owned element, whose ancestors the
|
|
7
|
+
* walk has not seen.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isDisabledByAncestor(element: Element): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The states map for an element with the given role; {} when there are none.
|
|
12
|
+
* `disabledByAncestor` is whether an ancestor sets aria-disabled, which the
|
|
13
|
+
* walk knows without climbing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function computeStates(element: Element, role: string, disabledByAncestor: boolean): Record<string, StateValue>;
|
|
16
|
+
/** The current value for textbox, searchbox, combobox and range roles; null when the field is absent. */
|
|
17
|
+
export declare function computeValue(element: Element, role: string): string | null;
|
|
18
|
+
//# sourceMappingURL=states.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"states.d.ts","sourceRoot":"","sources":["../../../../typescript/core/accessibility/states.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAwH5C,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE1D;AAWD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAO9D;AA2BD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CA8BrH;AAED,yGAAyG;AACzG,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE1E"}
|