@cronn/playwright-semantic-snapshots 0.0.0-stage → 0.36.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/LICENSE +201 -0
- package/README.md +154 -2
- package/dist/browser-lib.iife.js +919 -0
- package/dist/index.d.mts +268 -0
- package/dist/index.mjs +331 -0
- package/package.json +77 -3
|
@@ -0,0 +1,919 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
// src/browser/attribute.ts
|
|
3
|
+
function stringAttribute(value) {
|
|
4
|
+
return value !== null && value !== "" ? value : void 0;
|
|
5
|
+
}
|
|
6
|
+
function booleanAttribute(value) {
|
|
7
|
+
return value === true || value === "true" ? true : void 0;
|
|
8
|
+
}
|
|
9
|
+
function integerAttribute(value) {
|
|
10
|
+
if (value === null) return;
|
|
11
|
+
const parsedValue = parseInt(value);
|
|
12
|
+
return Number.isNaN(parsedValue) ? void 0 : parsedValue;
|
|
13
|
+
}
|
|
14
|
+
function decimalAttribute(value) {
|
|
15
|
+
if (value === null || value.trim() === "") return;
|
|
16
|
+
const parsedValue = Number(value);
|
|
17
|
+
return Number.isFinite(parsedValue) ? parsedValue : void 0;
|
|
18
|
+
}
|
|
19
|
+
function enumAttribute(value, supportedValues) {
|
|
20
|
+
if (value === null || !supportedValues.has(value)) return;
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
function booleanOrEnumAttribute(value, supportedStringValues) {
|
|
24
|
+
if (value === "true" || value === "false") return booleanAttribute(value);
|
|
25
|
+
return enumAttribute(value, supportedStringValues);
|
|
26
|
+
}
|
|
27
|
+
// src/utils/factories.ts
|
|
28
|
+
function textSnapshot(name) {
|
|
29
|
+
return {
|
|
30
|
+
role: "text",
|
|
31
|
+
name
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function elementSnapshot(values) {
|
|
35
|
+
return {
|
|
36
|
+
role: values.role,
|
|
37
|
+
name: values.name,
|
|
38
|
+
attributes: values.attributes ?? {},
|
|
39
|
+
children: values.children ?? []
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// src/utils/guards.ts
|
|
43
|
+
function isTextSnapshot(snapshot) {
|
|
44
|
+
return hasRole("text", snapshot);
|
|
45
|
+
}
|
|
46
|
+
function hasRole(role, snapshot) {
|
|
47
|
+
if (typeof role === "string") return role === snapshot.role;
|
|
48
|
+
return role.includes(snapshot.role);
|
|
49
|
+
}
|
|
50
|
+
// src/utils/filter.ts
|
|
51
|
+
function filter(options) {
|
|
52
|
+
const { predicate, snapshots, recurse = false } = options;
|
|
53
|
+
return snapshots.flatMap((snapshot) => {
|
|
54
|
+
const isFilteredIn = predicate(snapshot);
|
|
55
|
+
if (isFilteredIn && !recurse) return snapshot;
|
|
56
|
+
if (!isFilteredIn && recurse) return [];
|
|
57
|
+
const filteredChildren = hasChildren(snapshot) ? filter({
|
|
58
|
+
predicate,
|
|
59
|
+
snapshots: snapshot.children ?? [],
|
|
60
|
+
recurse
|
|
61
|
+
}) : [];
|
|
62
|
+
if (!isFilteredIn) return filteredChildren;
|
|
63
|
+
if (isTextSnapshot(snapshot)) return snapshot;
|
|
64
|
+
return {
|
|
65
|
+
...snapshot,
|
|
66
|
+
children: filteredChildren
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function hasChildren(snapshot) {
|
|
71
|
+
return "children" in snapshot && snapshot.children.length > 0;
|
|
72
|
+
}
|
|
73
|
+
// src/utils/text.ts
|
|
74
|
+
/**
|
|
75
|
+
* Aggregates and normalizes the text content of all provided snapshots
|
|
76
|
+
*/
|
|
77
|
+
function getTextContent(snapshots) {
|
|
78
|
+
return mergeTexts(filter({
|
|
79
|
+
snapshots,
|
|
80
|
+
predicate: isTextSnapshot
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
function normalizeText(text) {
|
|
84
|
+
return text.replaceAll(/\s+/g, " ").trim();
|
|
85
|
+
}
|
|
86
|
+
function mergeTexts(texts) {
|
|
87
|
+
return normalizeText(texts.map((textNode) => textNode.name).join(" "));
|
|
88
|
+
}
|
|
89
|
+
// src/browser/children.ts
|
|
90
|
+
function snapshotChildren(node, excludedNodes = []) {
|
|
91
|
+
return mergeConsecutiveTexts(Array.from(node.childNodes).map((childNode) => snapshotNodeRecursive(childNode, excludedNodes)).filter((childSnapshot) => childSnapshot !== null).flat());
|
|
92
|
+
}
|
|
93
|
+
function mergeConsecutiveTexts(children) {
|
|
94
|
+
return children.reduce((mergedChildren, child) => {
|
|
95
|
+
const lastMergedChildIndex = mergedChildren.length - 1;
|
|
96
|
+
const lastMergedChild = mergedChildren[lastMergedChildIndex];
|
|
97
|
+
if (lastMergedChild !== void 0 && isTextSnapshot(lastMergedChild) && isTextSnapshot(child)) mergedChildren[lastMergedChildIndex] = textSnapshot(mergeTexts([lastMergedChild, child]));
|
|
98
|
+
else mergedChildren.push(child);
|
|
99
|
+
return mergedChildren;
|
|
100
|
+
}, []);
|
|
101
|
+
}
|
|
102
|
+
// src/types/elements/container.ts
|
|
103
|
+
const CONTAINER_ROLES = /* @__PURE__ */ new Set([
|
|
104
|
+
"alert",
|
|
105
|
+
"article",
|
|
106
|
+
"banner",
|
|
107
|
+
"blockquote",
|
|
108
|
+
"code",
|
|
109
|
+
"complementary",
|
|
110
|
+
"contentinfo",
|
|
111
|
+
"definition",
|
|
112
|
+
"deletion",
|
|
113
|
+
"descriptionlist",
|
|
114
|
+
"emphasis",
|
|
115
|
+
"form",
|
|
116
|
+
"grid",
|
|
117
|
+
"insertion",
|
|
118
|
+
"label",
|
|
119
|
+
"list",
|
|
120
|
+
"listitem",
|
|
121
|
+
"log",
|
|
122
|
+
"main",
|
|
123
|
+
"mark",
|
|
124
|
+
"menu",
|
|
125
|
+
"navigation",
|
|
126
|
+
"note",
|
|
127
|
+
"paragraph",
|
|
128
|
+
"row",
|
|
129
|
+
"rowgroup",
|
|
130
|
+
"search",
|
|
131
|
+
"status",
|
|
132
|
+
"strong",
|
|
133
|
+
"subscript",
|
|
134
|
+
"superscript",
|
|
135
|
+
"table",
|
|
136
|
+
"tablist",
|
|
137
|
+
"tabpanel",
|
|
138
|
+
"term",
|
|
139
|
+
"toolbar",
|
|
140
|
+
"tree"
|
|
141
|
+
]);
|
|
142
|
+
// src/browser/container.ts
|
|
143
|
+
function snapshotContainer(role, element) {
|
|
144
|
+
const children = snapshotChildren(element);
|
|
145
|
+
return elementSnapshot({
|
|
146
|
+
role,
|
|
147
|
+
name: resolveAccessibleName(element),
|
|
148
|
+
children
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function isContainerRole(role) {
|
|
152
|
+
return CONTAINER_ROLES.has(role);
|
|
153
|
+
}
|
|
154
|
+
// src/browser/selector.ts
|
|
155
|
+
function selectorList(...selectors) {
|
|
156
|
+
return selectors.join(",");
|
|
157
|
+
}
|
|
158
|
+
function roleSelector(roleName) {
|
|
159
|
+
return attributeSelector("role", roleName);
|
|
160
|
+
}
|
|
161
|
+
function attributeSelector(name, value) {
|
|
162
|
+
return `[${name}='${value}']`;
|
|
163
|
+
}
|
|
164
|
+
// src/browser/utils.ts
|
|
165
|
+
function getElementTagName(element) {
|
|
166
|
+
return element.localName;
|
|
167
|
+
}
|
|
168
|
+
function isWithinElement(element, containerSelector) {
|
|
169
|
+
return element.closest(containerSelector) !== null;
|
|
170
|
+
}
|
|
171
|
+
// src/browser/role.ts
|
|
172
|
+
const ELEMENT_ROLES = {
|
|
173
|
+
a: "link",
|
|
174
|
+
article: "article",
|
|
175
|
+
aside: "complementary",
|
|
176
|
+
blockquote: "blockquote",
|
|
177
|
+
button: "button",
|
|
178
|
+
code: "code",
|
|
179
|
+
dd: "definition",
|
|
180
|
+
del: "deletion",
|
|
181
|
+
details: "group",
|
|
182
|
+
dl: "descriptionlist",
|
|
183
|
+
dt: "term",
|
|
184
|
+
em: "emphasis",
|
|
185
|
+
fieldset: "group",
|
|
186
|
+
footer: "contentinfo",
|
|
187
|
+
form: "form",
|
|
188
|
+
h1: "heading",
|
|
189
|
+
h2: "heading",
|
|
190
|
+
h3: "heading",
|
|
191
|
+
h4: "heading",
|
|
192
|
+
h5: "heading",
|
|
193
|
+
h6: "heading",
|
|
194
|
+
header: "banner",
|
|
195
|
+
hr: "separator",
|
|
196
|
+
img: "img",
|
|
197
|
+
input: resolveInputRole,
|
|
198
|
+
ins: "insertion",
|
|
199
|
+
label: "label",
|
|
200
|
+
legend: "label",
|
|
201
|
+
li: "listitem",
|
|
202
|
+
main: "main",
|
|
203
|
+
mark: "mark",
|
|
204
|
+
nav: "navigation",
|
|
205
|
+
ol: "list",
|
|
206
|
+
option: "option",
|
|
207
|
+
optgroup: "group",
|
|
208
|
+
output: "status",
|
|
209
|
+
p: "paragraph",
|
|
210
|
+
progress: "progressbar",
|
|
211
|
+
search: "search",
|
|
212
|
+
section: "region",
|
|
213
|
+
select: resolveSelectRole,
|
|
214
|
+
strong: "strong",
|
|
215
|
+
sub: "subscript",
|
|
216
|
+
sup: "superscript",
|
|
217
|
+
table: "table",
|
|
218
|
+
tbody: "rowgroup",
|
|
219
|
+
textarea: "textbox",
|
|
220
|
+
td: "cell",
|
|
221
|
+
tfoot: "rowgroup",
|
|
222
|
+
th: resolveTableHeaderCellRole,
|
|
223
|
+
thead: "rowgroup",
|
|
224
|
+
tr: "row",
|
|
225
|
+
ul: "list"
|
|
226
|
+
};
|
|
227
|
+
const CONTEXT_DEPENDENT_ROLES = {
|
|
228
|
+
banner: isTopLevelBanner,
|
|
229
|
+
cell: isWithinTableRow,
|
|
230
|
+
columnheader: isWithinTableRowOrGridRow,
|
|
231
|
+
definition: isWithinDescriptionList,
|
|
232
|
+
gridcell: isWithinGridRow,
|
|
233
|
+
listitem: isWithinList,
|
|
234
|
+
menuitem: isWithinMenu,
|
|
235
|
+
row: isWithinTableOrGrid,
|
|
236
|
+
rowgroup: isWithinTableOrGrid,
|
|
237
|
+
rowheader: isWithinTableRowOrGridRow,
|
|
238
|
+
tab: isWithinTablist,
|
|
239
|
+
term: isWithinDescriptionList,
|
|
240
|
+
treeitem: isWithinTree
|
|
241
|
+
};
|
|
242
|
+
const INPUT_ROLES = {
|
|
243
|
+
button: "button",
|
|
244
|
+
checkbox: "checkbox",
|
|
245
|
+
email: "textbox",
|
|
246
|
+
image: "button",
|
|
247
|
+
number: "spinbutton",
|
|
248
|
+
radio: "radio",
|
|
249
|
+
range: "slider",
|
|
250
|
+
reset: "button",
|
|
251
|
+
search: "searchbox",
|
|
252
|
+
submit: "button",
|
|
253
|
+
tel: "textbox",
|
|
254
|
+
text: "textbox",
|
|
255
|
+
url: "textbox"
|
|
256
|
+
};
|
|
257
|
+
const COMBOBOX_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
258
|
+
"email",
|
|
259
|
+
"search",
|
|
260
|
+
"tel",
|
|
261
|
+
"text",
|
|
262
|
+
"url"
|
|
263
|
+
]);
|
|
264
|
+
function parseElementRole(element) {
|
|
265
|
+
const resolvedElementRole = resolveElementRole(element);
|
|
266
|
+
if (resolvedElementRole === void 0) return;
|
|
267
|
+
const isValidInContext = CONTEXT_DEPENDENT_ROLES[resolvedElementRole];
|
|
268
|
+
if (isValidInContext !== void 0 && !isValidInContext(element, resolvedElementRole)) return;
|
|
269
|
+
return resolvedElementRole;
|
|
270
|
+
}
|
|
271
|
+
function resolveElementRole(element) {
|
|
272
|
+
const explicitRole = element.role;
|
|
273
|
+
if (isIgnoredRole(explicitRole)) return;
|
|
274
|
+
if (explicitRole !== null && (hasRoleSpecificSnapshot(explicitRole) || isContainerRole(explicitRole))) return explicitRole;
|
|
275
|
+
const tagName = getElementTagName(element);
|
|
276
|
+
const roleResolver = ELEMENT_ROLES[tagName];
|
|
277
|
+
if (roleResolver === void 0) return;
|
|
278
|
+
if (typeof roleResolver === "string") return roleResolver;
|
|
279
|
+
return roleResolver(element);
|
|
280
|
+
}
|
|
281
|
+
function isIgnoredRole(role) {
|
|
282
|
+
return role === "presentation" || role === "none";
|
|
283
|
+
}
|
|
284
|
+
function resolveInputRole(element) {
|
|
285
|
+
if (!(element instanceof HTMLInputElement)) return;
|
|
286
|
+
if (COMBOBOX_INPUT_TYPES.has(element.type) && element.list !== null) return "combobox";
|
|
287
|
+
return INPUT_ROLES[element.type] ?? "textbox";
|
|
288
|
+
}
|
|
289
|
+
function resolveSelectRole(element) {
|
|
290
|
+
if (!(element instanceof HTMLSelectElement)) return;
|
|
291
|
+
if (element.multiple || element.size > 1) return "listbox";
|
|
292
|
+
return "combobox";
|
|
293
|
+
}
|
|
294
|
+
const DISALLOWED_BANNER_CONTAINER_ELEMENTS = [
|
|
295
|
+
"article",
|
|
296
|
+
"aside",
|
|
297
|
+
"main",
|
|
298
|
+
"nav",
|
|
299
|
+
"section"
|
|
300
|
+
];
|
|
301
|
+
const DISALLOWED_BANNER_CONTAINER_ROLES = [
|
|
302
|
+
"article",
|
|
303
|
+
"complementary",
|
|
304
|
+
"main",
|
|
305
|
+
"navigation",
|
|
306
|
+
"region"
|
|
307
|
+
];
|
|
308
|
+
const DISALLOWED_BANNER_CONTAINER_SELECTOR = selectorList(...DISALLOWED_BANNER_CONTAINER_ELEMENTS, ...DISALLOWED_BANNER_CONTAINER_ROLES.map(roleSelector));
|
|
309
|
+
function isTopLevelBanner(element) {
|
|
310
|
+
return !isWithinElement(element, DISALLOWED_BANNER_CONTAINER_SELECTOR);
|
|
311
|
+
}
|
|
312
|
+
function isWithinDescriptionList(element) {
|
|
313
|
+
return isWithinElement(element, "dl");
|
|
314
|
+
}
|
|
315
|
+
function resolveTableHeaderCellRole(element) {
|
|
316
|
+
if (!(element instanceof HTMLTableCellElement)) return;
|
|
317
|
+
switch (element.scope) {
|
|
318
|
+
case "col":
|
|
319
|
+
case "colgroup": return "columnheader";
|
|
320
|
+
case "row":
|
|
321
|
+
case "rowgroup": return "rowheader";
|
|
322
|
+
default: return resolveTableHeaderCellRoleFromContext(element);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function resolveTableHeaderCellRoleFromContext(element) {
|
|
326
|
+
const row = element.parentElement;
|
|
327
|
+
if (!(row instanceof HTMLTableRowElement)) return;
|
|
328
|
+
const nextCell = row.cells[element.cellIndex + 1] ?? null;
|
|
329
|
+
if (row.rowIndex === 0 && (nextCell === null || resolveElementRole(nextCell) === "columnheader")) return "columnheader";
|
|
330
|
+
if (element.cellIndex === 0 && nextCell !== null && resolveElementRole(nextCell) === "cell") return "rowheader";
|
|
331
|
+
}
|
|
332
|
+
const TABLE_SELECTOR = selectorList("table", roleSelector("table"));
|
|
333
|
+
const GRID_SELECTOR = roleSelector("grid");
|
|
334
|
+
const ROW_SELECTOR = selectorList("tr", roleSelector("row"));
|
|
335
|
+
const LIST_SELECTOR = selectorList("ul", "ol", roleSelector("list"));
|
|
336
|
+
function isWithinTableOrGrid(element) {
|
|
337
|
+
return isWithinTable(element) || isWithinGrid(element);
|
|
338
|
+
}
|
|
339
|
+
function isWithinTable(element) {
|
|
340
|
+
return isWithinElement(element, TABLE_SELECTOR);
|
|
341
|
+
}
|
|
342
|
+
function isWithinGrid(element) {
|
|
343
|
+
return isWithinElement(element, GRID_SELECTOR);
|
|
344
|
+
}
|
|
345
|
+
function isWithinTableRowOrGridRow(element) {
|
|
346
|
+
const closestRow = element.closest(ROW_SELECTOR);
|
|
347
|
+
return closestRow !== null && isWithinTableOrGrid(closestRow);
|
|
348
|
+
}
|
|
349
|
+
function isWithinTableRow(element) {
|
|
350
|
+
const closestRow = element.closest(ROW_SELECTOR);
|
|
351
|
+
return closestRow !== null && isWithinTable(closestRow);
|
|
352
|
+
}
|
|
353
|
+
function isWithinGridRow(element) {
|
|
354
|
+
const closestRow = element.closest(ROW_SELECTOR);
|
|
355
|
+
return closestRow !== null && isWithinGrid(closestRow);
|
|
356
|
+
}
|
|
357
|
+
function isWithinList(element) {
|
|
358
|
+
return isWithinElement(element, LIST_SELECTOR);
|
|
359
|
+
}
|
|
360
|
+
function isWithinMenu(element) {
|
|
361
|
+
return isWithinElement(element, roleSelector("menu"));
|
|
362
|
+
}
|
|
363
|
+
function isWithinTablist(element) {
|
|
364
|
+
return isWithinElement(element, roleSelector("tablist"));
|
|
365
|
+
}
|
|
366
|
+
function isWithinTree(element) {
|
|
367
|
+
return isWithinElement(element, roleSelector("tree"));
|
|
368
|
+
}
|
|
369
|
+
// src/browser/text.ts
|
|
370
|
+
function snapshotTextNode(textNode) {
|
|
371
|
+
if (textNode.textContent === null) return null;
|
|
372
|
+
const normalizedText = normalizeText(textNode.textContent);
|
|
373
|
+
if (normalizedText.length === 0) return null;
|
|
374
|
+
return textSnapshot(normalizedText);
|
|
375
|
+
}
|
|
376
|
+
function snapshotPresentationalChildren(node) {
|
|
377
|
+
const accessibleTextContent = resolveAccessibleTextContent(node);
|
|
378
|
+
if (accessibleTextContent === void 0 || accessibleTextContent.length === 0) return [];
|
|
379
|
+
return [textSnapshot(accessibleTextContent)];
|
|
380
|
+
}
|
|
381
|
+
function resolveAccessibleTextContent(node, excludedNodes = []) {
|
|
382
|
+
const children = snapshotChildren(node, excludedNodes);
|
|
383
|
+
if (children === void 0) return;
|
|
384
|
+
const textContent = getTextContent(children);
|
|
385
|
+
return textContent.length > 0 ? textContent : void 0;
|
|
386
|
+
}
|
|
387
|
+
function resolveJoinedAccessibleTextContent(nodes, excludedNodes = []) {
|
|
388
|
+
const textContents = nodes.map((node) => resolveAccessibleTextContent(node, excludedNodes)).filter((textContent) => textContent !== void 0);
|
|
389
|
+
return textContents.length > 0 ? textContents.join(" ") : void 0;
|
|
390
|
+
}
|
|
391
|
+
// src/browser/name.ts
|
|
392
|
+
const prohibitsNaming = /* @__PURE__ */ new Set([
|
|
393
|
+
"code",
|
|
394
|
+
"emphasis",
|
|
395
|
+
"label",
|
|
396
|
+
"listitem",
|
|
397
|
+
"paragraph",
|
|
398
|
+
"rowgroup",
|
|
399
|
+
"strong",
|
|
400
|
+
"term"
|
|
401
|
+
]);
|
|
402
|
+
const supportsNamingByLabel = /* @__PURE__ */ new Set([
|
|
403
|
+
"checkbox",
|
|
404
|
+
"combobox",
|
|
405
|
+
"listbox",
|
|
406
|
+
"progressbar",
|
|
407
|
+
"radio",
|
|
408
|
+
"searchbox",
|
|
409
|
+
"slider",
|
|
410
|
+
"spinbutton",
|
|
411
|
+
"textbox"
|
|
412
|
+
]);
|
|
413
|
+
const supportsNamingFromChildContent = /* @__PURE__ */ new Set([
|
|
414
|
+
"button",
|
|
415
|
+
"cell",
|
|
416
|
+
"columnheader",
|
|
417
|
+
"gridcell",
|
|
418
|
+
"heading",
|
|
419
|
+
"link",
|
|
420
|
+
"menuitem",
|
|
421
|
+
"option",
|
|
422
|
+
"rowheader",
|
|
423
|
+
"tab"
|
|
424
|
+
]);
|
|
425
|
+
const contextBasedNameResolvers = [
|
|
426
|
+
resolveImageName,
|
|
427
|
+
resolveLegendName,
|
|
428
|
+
resolveOptionLabelName,
|
|
429
|
+
resolveOptgroupLabelName,
|
|
430
|
+
resolveTreeItemName
|
|
431
|
+
];
|
|
432
|
+
function resolveAccessibleName(element) {
|
|
433
|
+
const role = parseElementRole(element);
|
|
434
|
+
if (role === void 0 || prohibitsNaming.has(role)) return;
|
|
435
|
+
const labelledByElements = element.ariaLabelledByElements ?? [];
|
|
436
|
+
if (labelledByElements.length > 0) return resolveJoinedAccessibleTextContent(labelledByElements);
|
|
437
|
+
if (element.ariaLabel !== null) return element.ariaLabel;
|
|
438
|
+
for (const resolveName of contextBasedNameResolvers) {
|
|
439
|
+
const name = resolveName(element, role);
|
|
440
|
+
if (name !== void 0) return name;
|
|
441
|
+
}
|
|
442
|
+
if (supportsNamingByLabel.has(role)) return resolveLabelName(element);
|
|
443
|
+
if (supportsNamingFromChildContent.has(role)) return resolveAccessibleTextContent(element);
|
|
444
|
+
}
|
|
445
|
+
function resolveLabelName(element) {
|
|
446
|
+
return resolveJoinedAccessibleTextContent(resolveLabels(element), [element]);
|
|
447
|
+
}
|
|
448
|
+
function resolveLabels(element) {
|
|
449
|
+
if (!("labels" in element)) return [];
|
|
450
|
+
return Array.from(element.labels ?? []);
|
|
451
|
+
}
|
|
452
|
+
function resolveLegendName(element) {
|
|
453
|
+
if (!(element instanceof HTMLFieldSetElement)) return;
|
|
454
|
+
const legendElement = element.querySelector(":scope > legend");
|
|
455
|
+
if (legendElement === null) return;
|
|
456
|
+
return resolveAccessibleTextContent(legendElement);
|
|
457
|
+
}
|
|
458
|
+
function resolveOptionLabelName(element) {
|
|
459
|
+
if (!(element instanceof HTMLOptionElement)) return;
|
|
460
|
+
return stringAttribute(normalizeText(element.getAttribute("label") ?? ""));
|
|
461
|
+
}
|
|
462
|
+
function resolveOptgroupLabelName(element) {
|
|
463
|
+
if (!(element instanceof HTMLOptGroupElement)) return;
|
|
464
|
+
return stringAttribute(normalizeText(element.label));
|
|
465
|
+
}
|
|
466
|
+
function resolveImageName(element, role) {
|
|
467
|
+
if (element instanceof HTMLImageElement) return stringAttribute(element.alt);
|
|
468
|
+
if (role === "img") return resolveAccessibleTextContent(element);
|
|
469
|
+
}
|
|
470
|
+
function resolveTreeItemName(element, role) {
|
|
471
|
+
if (role !== "treeitem") return;
|
|
472
|
+
return resolveAccessibleTextContent(element, Array.from(element.querySelectorAll(roleSelector("group"))));
|
|
473
|
+
}
|
|
474
|
+
// src/browser/state.ts
|
|
475
|
+
function disableableAttributes(element) {
|
|
476
|
+
return { disabled: booleanAttribute(element.matches(":disabled")) ?? booleanAttribute(element.ariaDisabled) };
|
|
477
|
+
}
|
|
478
|
+
function selectableAttributes(element) {
|
|
479
|
+
if (element instanceof HTMLOptionElement) return { selected: booleanAttribute(element.selected) };
|
|
480
|
+
return { selected: booleanAttribute(element.ariaSelected) };
|
|
481
|
+
}
|
|
482
|
+
function multiselectableAttributes(element) {
|
|
483
|
+
if (element instanceof HTMLSelectElement) return { multiselectable: booleanAttribute(element.multiple) };
|
|
484
|
+
return { multiselectable: booleanAttribute(element.ariaMultiSelectable) };
|
|
485
|
+
}
|
|
486
|
+
function expandableAttributes(element) {
|
|
487
|
+
return { expanded: booleanAttribute(element.ariaExpanded) };
|
|
488
|
+
}
|
|
489
|
+
const checkedValues = /* @__PURE__ */ new Set(["mixed"]);
|
|
490
|
+
function checkableAttributes(element) {
|
|
491
|
+
return { checked: booleanOrEnumAttribute(element.ariaChecked, checkedValues) };
|
|
492
|
+
}
|
|
493
|
+
function inputStateAttributes(element) {
|
|
494
|
+
return {
|
|
495
|
+
readonly: booleanAttribute(isReadonly(element)) ?? booleanAttribute(element.ariaReadOnly),
|
|
496
|
+
...disableableAttributes(element),
|
|
497
|
+
required: booleanAttribute(element.matches(":required")) ?? booleanAttribute(element.ariaRequired),
|
|
498
|
+
invalid: booleanAttribute(element.ariaInvalid)
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Input types supporting the `readonly` attribute
|
|
503
|
+
*
|
|
504
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/readonly#attribute_interactions
|
|
505
|
+
*/
|
|
506
|
+
const READONLY_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
507
|
+
"text",
|
|
508
|
+
"search",
|
|
509
|
+
"url",
|
|
510
|
+
"tel",
|
|
511
|
+
"email",
|
|
512
|
+
"password",
|
|
513
|
+
"date",
|
|
514
|
+
"month",
|
|
515
|
+
"week",
|
|
516
|
+
"time",
|
|
517
|
+
"datetime-local",
|
|
518
|
+
"number"
|
|
519
|
+
]);
|
|
520
|
+
function isReadonly(element) {
|
|
521
|
+
if (element instanceof HTMLTextAreaElement) return element.readOnly;
|
|
522
|
+
if (element instanceof HTMLInputElement) return READONLY_INPUT_TYPES.has(element.type) && element.readOnly;
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
// src/browser/button.ts
|
|
526
|
+
const pressedValues = /* @__PURE__ */ new Set(["mixed"]);
|
|
527
|
+
function snapshotButton(element) {
|
|
528
|
+
return {
|
|
529
|
+
role: "button",
|
|
530
|
+
name: resolveAccessibleName(element),
|
|
531
|
+
attributes: {
|
|
532
|
+
...disableableAttributes(element),
|
|
533
|
+
...expandableAttributes(element),
|
|
534
|
+
pressed: booleanOrEnumAttribute(element.ariaPressed, pressedValues)
|
|
535
|
+
},
|
|
536
|
+
children: snapshotChildren(element)
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
// src/utils/array.ts
|
|
540
|
+
function unwrapSingleItem(items) {
|
|
541
|
+
return items.length === 1 ? items.at(0) : items;
|
|
542
|
+
}
|
|
543
|
+
// src/browser/description.ts
|
|
544
|
+
function discribableAttributes(element) {
|
|
545
|
+
return { description: resolveDescription(element) };
|
|
546
|
+
}
|
|
547
|
+
function resolveDescription(element) {
|
|
548
|
+
const describedByElements = element.ariaDescribedByElements ?? [];
|
|
549
|
+
if (describedByElements.length > 0) return resolveJoinedAccessibleTextContent(describedByElements);
|
|
550
|
+
if (element.ariaDescription !== null) return element.ariaDescription;
|
|
551
|
+
}
|
|
552
|
+
// src/browser/input.ts
|
|
553
|
+
function snapshotInput(element) {
|
|
554
|
+
if (element instanceof HTMLInputElement) return snapshotInputElement(element);
|
|
555
|
+
if (element instanceof HTMLTextAreaElement) return snapshotTextareaElement(element);
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
function snapshotInputElement(element) {
|
|
559
|
+
const inputRole = resolveInputRole(element);
|
|
560
|
+
if (inputRole === void 0 || inputRole === "button" || inputRole === "combobox") return null;
|
|
561
|
+
return elementSnapshot({
|
|
562
|
+
role: inputRole,
|
|
563
|
+
name: resolveAccessibleName(element),
|
|
564
|
+
attributes: {
|
|
565
|
+
value: resolveInputValue(element),
|
|
566
|
+
checked: resolveChecked(element),
|
|
567
|
+
...snapshotCommonInputAttributes(element)
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function snapshotTextareaElement(element) {
|
|
572
|
+
return elementSnapshot({
|
|
573
|
+
role: "textbox",
|
|
574
|
+
name: resolveAccessibleName(element),
|
|
575
|
+
attributes: {
|
|
576
|
+
value: resolveInputValue(element),
|
|
577
|
+
...snapshotCommonInputAttributes(element)
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
function snapshotCommonInputAttributes(element) {
|
|
582
|
+
return {
|
|
583
|
+
...discribableAttributes(element),
|
|
584
|
+
placeholder: resolvePlaceholder(element),
|
|
585
|
+
...inputStateAttributes(element)
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
const CHECKED_INPUT_TYPES = /* @__PURE__ */ new Set(["checkbox", "radio"]);
|
|
589
|
+
function resolveInputValue(element) {
|
|
590
|
+
if (element instanceof HTMLInputElement && CHECKED_INPUT_TYPES.has(element.type)) return;
|
|
591
|
+
return stringAttribute(element.value);
|
|
592
|
+
}
|
|
593
|
+
function resolveChecked(element) {
|
|
594
|
+
if (element.type === "checkbox" && element.indeterminate) return "mixed";
|
|
595
|
+
return element.checked ? true : void 0;
|
|
596
|
+
}
|
|
597
|
+
function resolvePlaceholder(element) {
|
|
598
|
+
if (!(element instanceof HTMLInputElement) && !(element instanceof HTMLTextAreaElement)) return;
|
|
599
|
+
return stringAttribute(element.placeholder);
|
|
600
|
+
}
|
|
601
|
+
// src/browser/combobox.ts
|
|
602
|
+
function snapshotCombobox(element) {
|
|
603
|
+
if (!isCombobox(element)) return null;
|
|
604
|
+
return {
|
|
605
|
+
role: "combobox",
|
|
606
|
+
name: resolveAccessibleName(element),
|
|
607
|
+
attributes: {
|
|
608
|
+
value: resolveValue$1(element),
|
|
609
|
+
...snapshotCommonInputAttributes(element),
|
|
610
|
+
...expandableAttributes(element)
|
|
611
|
+
},
|
|
612
|
+
children: snapshotChildren(element)
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function isCombobox(element) {
|
|
616
|
+
if (element instanceof HTMLSelectElement && element.role === null) return resolveSelectRole(element) === "combobox";
|
|
617
|
+
if (element instanceof HTMLInputElement && element.role === null) return resolveInputRole(element) === "combobox";
|
|
618
|
+
return element.role === "combobox";
|
|
619
|
+
}
|
|
620
|
+
function resolveValue$1(element) {
|
|
621
|
+
if (element instanceof HTMLInputElement) return resolveInputValue(element);
|
|
622
|
+
if (!(element instanceof HTMLSelectElement)) return resolveAccessibleTextContent(element);
|
|
623
|
+
const selectedLabels = Array.from(element.selectedOptions).map((option) => option.label);
|
|
624
|
+
if (selectedLabels.length === 0) return;
|
|
625
|
+
return unwrapSingleItem(selectedLabels);
|
|
626
|
+
}
|
|
627
|
+
function snapshotOption(element) {
|
|
628
|
+
return {
|
|
629
|
+
role: "option",
|
|
630
|
+
name: resolveAccessibleName(element),
|
|
631
|
+
attributes: {
|
|
632
|
+
...selectableAttributes(element),
|
|
633
|
+
...disableableAttributes(element)
|
|
634
|
+
},
|
|
635
|
+
children: snapshotChildren(element)
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
// src/browser/details.ts
|
|
639
|
+
function isCollapsedDetailsContent(node) {
|
|
640
|
+
const parentElement = node.parentElement;
|
|
641
|
+
return parentElement instanceof HTMLDetailsElement && !parentElement.open && parentElement.querySelector(":scope > summary") !== node;
|
|
642
|
+
}
|
|
643
|
+
// src/browser/dialog.ts
|
|
644
|
+
function snapshotDialogWithRole(role) {
|
|
645
|
+
return (element) => snapshotDialog(role, element);
|
|
646
|
+
}
|
|
647
|
+
function snapshotDialog(role, element) {
|
|
648
|
+
return {
|
|
649
|
+
role,
|
|
650
|
+
name: resolveAccessibleName(element),
|
|
651
|
+
attributes: {
|
|
652
|
+
...discribableAttributes(element),
|
|
653
|
+
modal: booleanAttribute(element.ariaModal)
|
|
654
|
+
},
|
|
655
|
+
children: snapshotChildren(element)
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
// src/browser/group.ts
|
|
659
|
+
function snapshotGroup(element) {
|
|
660
|
+
return elementSnapshot({
|
|
661
|
+
role: "group",
|
|
662
|
+
name: resolveAccessibleName(element),
|
|
663
|
+
children: snapshotChildren(element)
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
function snapshotRadioGroup(element) {
|
|
667
|
+
return {
|
|
668
|
+
role: "radiogroup",
|
|
669
|
+
name: resolveAccessibleName(element),
|
|
670
|
+
attributes: discribableAttributes(element),
|
|
671
|
+
children: snapshotChildren(element)
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
// src/browser/heading.ts
|
|
675
|
+
/** Implicit `aria-level` of the `heading` role */
|
|
676
|
+
const DEFAULT_LEVEL = 2;
|
|
677
|
+
function snapshotHeading(element) {
|
|
678
|
+
return {
|
|
679
|
+
role: "heading",
|
|
680
|
+
name: resolveAccessibleName(element),
|
|
681
|
+
attributes: { level: resolveLevel(element) },
|
|
682
|
+
children: snapshotChildren(element)
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function resolveLevel(element) {
|
|
686
|
+
const ariaLevel = integerAttribute(element.ariaLevel);
|
|
687
|
+
if (ariaLevel !== void 0 && ariaLevel >= 1) return ariaLevel;
|
|
688
|
+
if (element instanceof HTMLHeadingElement) return Number(element.localName.slice(1));
|
|
689
|
+
return DEFAULT_LEVEL;
|
|
690
|
+
}
|
|
691
|
+
// src/browser/image.ts
|
|
692
|
+
function snapshotImage(element) {
|
|
693
|
+
const imageName = resolveAccessibleName(element);
|
|
694
|
+
if (imageName === void 0) return null;
|
|
695
|
+
return elementSnapshot({
|
|
696
|
+
role: "img",
|
|
697
|
+
name: imageName
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
// src/browser/link.ts
|
|
701
|
+
const currentValues = /* @__PURE__ */ new Set(["page", "step"]);
|
|
702
|
+
function snapshotLink(element) {
|
|
703
|
+
return {
|
|
704
|
+
role: "link",
|
|
705
|
+
name: resolveAccessibleName(element),
|
|
706
|
+
attributes: linkAttributes(element),
|
|
707
|
+
children: snapshotChildren(element)
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function linkAttributes(element) {
|
|
711
|
+
return {
|
|
712
|
+
url: stringAttribute(element.getAttribute("href")),
|
|
713
|
+
current: booleanOrEnumAttribute(element.ariaCurrent, currentValues)
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
// src/browser/list.ts
|
|
717
|
+
function snapshotMenuitem(element) {
|
|
718
|
+
return {
|
|
719
|
+
role: "menuitem",
|
|
720
|
+
name: resolveAccessibleName(element),
|
|
721
|
+
attributes: {
|
|
722
|
+
...linkAttributes(element),
|
|
723
|
+
...disableableAttributes(element)
|
|
724
|
+
},
|
|
725
|
+
children: snapshotChildren(element)
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
// src/browser/listbox.ts
|
|
729
|
+
function snapshotListbox(element) {
|
|
730
|
+
return {
|
|
731
|
+
role: "listbox",
|
|
732
|
+
name: resolveAccessibleName(element),
|
|
733
|
+
attributes: {
|
|
734
|
+
...multiselectableAttributes(element),
|
|
735
|
+
...snapshotCommonInputAttributes(element),
|
|
736
|
+
...expandableAttributes(element)
|
|
737
|
+
},
|
|
738
|
+
children: snapshotChildren(element)
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
// src/browser/progressbar.ts
|
|
742
|
+
function snapshotProgressbar(element) {
|
|
743
|
+
return {
|
|
744
|
+
role: "progressbar",
|
|
745
|
+
name: resolveAccessibleName(element),
|
|
746
|
+
attributes: { value: resolveValue(element) },
|
|
747
|
+
children: snapshotPresentationalChildren(element)
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
function resolveValue(element) {
|
|
751
|
+
if (element instanceof HTMLProgressElement) return element.position === -1 ? void 0 : element.value;
|
|
752
|
+
return decimalAttribute(element.ariaValueNow);
|
|
753
|
+
}
|
|
754
|
+
// src/browser/region.ts
|
|
755
|
+
function snapshotRegion(element) {
|
|
756
|
+
const name = resolveAccessibleName(element);
|
|
757
|
+
const children = snapshotChildren(element);
|
|
758
|
+
if (name === void 0) return children;
|
|
759
|
+
return elementSnapshot({
|
|
760
|
+
role: "region",
|
|
761
|
+
name,
|
|
762
|
+
children
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
// src/browser/separator.ts
|
|
766
|
+
function snapshotSeparator(element) {
|
|
767
|
+
return elementSnapshot({
|
|
768
|
+
role: "separator",
|
|
769
|
+
children: snapshotPresentationalChildren(element)
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
// src/browser/tab.ts
|
|
773
|
+
function snapshotTab(element) {
|
|
774
|
+
return {
|
|
775
|
+
role: "tab",
|
|
776
|
+
name: resolveAccessibleName(element),
|
|
777
|
+
attributes: {
|
|
778
|
+
...disableableAttributes(element),
|
|
779
|
+
...selectableAttributes(element)
|
|
780
|
+
},
|
|
781
|
+
children: snapshotChildren(element)
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
// src/types/elements/table.ts
|
|
785
|
+
const SORT_TYPES = /* @__PURE__ */ new Set([
|
|
786
|
+
"ascending",
|
|
787
|
+
"descending",
|
|
788
|
+
"other"
|
|
789
|
+
]);
|
|
790
|
+
// src/browser/table.ts
|
|
791
|
+
function snapshotColumnHeader(element) {
|
|
792
|
+
const cell = snapshotCell("columnheader", element);
|
|
793
|
+
return {
|
|
794
|
+
role: "columnheader",
|
|
795
|
+
name: cell.name,
|
|
796
|
+
attributes: {
|
|
797
|
+
...cell.attributes,
|
|
798
|
+
sort: enumAttribute(element.ariaSort, SORT_TYPES)
|
|
799
|
+
},
|
|
800
|
+
children: cell.children
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
function snapshotCellWithRole(role) {
|
|
804
|
+
return (element) => snapshotCell(role, element);
|
|
805
|
+
}
|
|
806
|
+
function snapshotCell(role, element) {
|
|
807
|
+
return {
|
|
808
|
+
role,
|
|
809
|
+
name: resolveAccessibleName(element),
|
|
810
|
+
attributes: cellAttributes(element),
|
|
811
|
+
children: snapshotChildren(element)
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
function cellAttributes(element) {
|
|
815
|
+
if (element instanceof HTMLTableCellElement) return {
|
|
816
|
+
colSpan: resolveSpan(element.colSpan),
|
|
817
|
+
rowSpan: resolveSpan(element.rowSpan)
|
|
818
|
+
};
|
|
819
|
+
return {
|
|
820
|
+
colSpan: resolveSpan(element.ariaColSpan),
|
|
821
|
+
rowSpan: resolveSpan(element.ariaRowSpan)
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
function resolveSpan(value) {
|
|
825
|
+
if (typeof value === "string") value = integerAttribute(value) ?? null;
|
|
826
|
+
if (value === null || value === 1) return;
|
|
827
|
+
return value;
|
|
828
|
+
}
|
|
829
|
+
// src/browser/tree.ts
|
|
830
|
+
function snapshotTreeItem(element) {
|
|
831
|
+
return {
|
|
832
|
+
role: "treeitem",
|
|
833
|
+
name: resolveAccessibleName(element),
|
|
834
|
+
attributes: {
|
|
835
|
+
...disableableAttributes(element),
|
|
836
|
+
...checkableAttributes(element),
|
|
837
|
+
...selectableAttributes(element),
|
|
838
|
+
...expandableAttributes(element)
|
|
839
|
+
},
|
|
840
|
+
children: snapshotChildren(element)
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
// src/browser/element.ts
|
|
844
|
+
const ROLE_SNAPSHOTS = {
|
|
845
|
+
alertdialog: snapshotDialogWithRole("alertdialog"),
|
|
846
|
+
button: snapshotButton,
|
|
847
|
+
cell: snapshotCellWithRole("cell"),
|
|
848
|
+
checkbox: snapshotInput,
|
|
849
|
+
columnheader: snapshotColumnHeader,
|
|
850
|
+
combobox: snapshotCombobox,
|
|
851
|
+
dialog: snapshotDialogWithRole("dialog"),
|
|
852
|
+
gridcell: snapshotCellWithRole("gridcell"),
|
|
853
|
+
group: snapshotGroup,
|
|
854
|
+
heading: snapshotHeading,
|
|
855
|
+
img: snapshotImage,
|
|
856
|
+
menuitem: snapshotMenuitem,
|
|
857
|
+
option: snapshotOption,
|
|
858
|
+
progressbar: snapshotProgressbar,
|
|
859
|
+
link: snapshotLink,
|
|
860
|
+
listbox: snapshotListbox,
|
|
861
|
+
radio: snapshotInput,
|
|
862
|
+
radiogroup: snapshotRadioGroup,
|
|
863
|
+
region: snapshotRegion,
|
|
864
|
+
rowheader: snapshotCellWithRole("rowheader"),
|
|
865
|
+
searchbox: snapshotInput,
|
|
866
|
+
separator: snapshotSeparator,
|
|
867
|
+
slider: snapshotInput,
|
|
868
|
+
spinbutton: snapshotInput,
|
|
869
|
+
tab: snapshotTab,
|
|
870
|
+
textbox: snapshotInput,
|
|
871
|
+
treeitem: snapshotTreeItem
|
|
872
|
+
};
|
|
873
|
+
function snapshotElement(element) {
|
|
874
|
+
return snapshotNodeRecursive(element);
|
|
875
|
+
}
|
|
876
|
+
function snapshotNodeRecursive(node, excludedNodes = []) {
|
|
877
|
+
const snapshot = snapshotNodeByType(node, excludedNodes);
|
|
878
|
+
if (snapshot === null) return [];
|
|
879
|
+
if (Array.isArray(snapshot)) return snapshot;
|
|
880
|
+
return [snapshot];
|
|
881
|
+
}
|
|
882
|
+
function snapshotNodeByType(node, excludedNodes) {
|
|
883
|
+
if (excludedNodes.includes(node) || isCollapsedDetailsContent(node)) return null;
|
|
884
|
+
if (node.nodeType === Node.TEXT_NODE) return snapshotTextNode(node);
|
|
885
|
+
if (!isSupportedElement(node) || isHiddenElement(node)) return null;
|
|
886
|
+
const elementRole = parseElementRole(node);
|
|
887
|
+
if (elementRole === void 0) return snapshotChildren(node, excludedNodes) ?? null;
|
|
888
|
+
if (hasRoleSpecificSnapshot(elementRole)) {
|
|
889
|
+
const snapshotByRole = ROLE_SNAPSHOTS[elementRole];
|
|
890
|
+
return snapshotByRole(node);
|
|
891
|
+
}
|
|
892
|
+
return snapshotContainer(elementRole, node);
|
|
893
|
+
}
|
|
894
|
+
const UNSUPPORTED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
895
|
+
"audio",
|
|
896
|
+
"figure",
|
|
897
|
+
"noscript",
|
|
898
|
+
"picture",
|
|
899
|
+
"script",
|
|
900
|
+
"style",
|
|
901
|
+
"template",
|
|
902
|
+
"video"
|
|
903
|
+
]);
|
|
904
|
+
function isSupportedElement(node) {
|
|
905
|
+
if (!(node instanceof HTMLElement || node instanceof SVGElement)) return false;
|
|
906
|
+
const tagName = getElementTagName(node);
|
|
907
|
+
return !UNSUPPORTED_ELEMENTS.has(tagName);
|
|
908
|
+
}
|
|
909
|
+
function hasRoleSpecificSnapshot(role) {
|
|
910
|
+
return role in ROLE_SNAPSHOTS;
|
|
911
|
+
}
|
|
912
|
+
function isHiddenElement(element) {
|
|
913
|
+
if (booleanAttribute(element.ariaHidden) === true) return true;
|
|
914
|
+
const cssStyles = window.getComputedStyle(element);
|
|
915
|
+
return cssStyles.display === "none" || cssStyles.visibility === "hidden" || cssStyles.visibility === "collapse" || cssStyles.contentVisibility === "hidden";
|
|
916
|
+
}
|
|
917
|
+
// src/browser-lib.ts
|
|
918
|
+
window.snapshotElement = snapshotElement;
|
|
919
|
+
})();
|