tab-trail 0.0.0-stage → 1.0.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +145 -2
- package/data/api.json +30 -0
- package/data/features.json +173 -0
- package/data/keys.json +10 -0
- package/data/limits.json +10 -0
- package/data/quiet.json +12 -0
- package/data/read.json +10 -0
- package/data/vs.json +6 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.mjs +14 -0
- package/dist/tab-trail.js +2836 -0
- package/package.json +52 -4
|
@@ -0,0 +1,2836 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tab trail 1.0.0, https://matjazkorosec.com/tools/tab-trail
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Matjaž Korošec
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
(function(){
|
|
27
|
+
/* Tab trail 1.0.0. Copyright (c) 2026 Matjaž Korošec. MIT License, full text: https://github.com/matjazkorosec/tab-trail/blob/main/LICENSE */
|
|
28
|
+
var VERSION = "1.0.0";
|
|
29
|
+
var ID = "tab-trail-host";
|
|
30
|
+
var prev = [].filter.call(document.querySelectorAll("[id='" + ID + "']"), function (e) { return typeof e.__close === "function"; })[0];
|
|
31
|
+
if (prev) { prev.__close(); return; }
|
|
32
|
+
var NS = "http://www.w3.org/2000/svg";
|
|
33
|
+
var FOCUSABLE = "a[href],area[href],button,input,select,textarea,iframe,summary,audio[controls],video[controls],[contenteditable]:not([contenteditable='false']),[tabindex]";
|
|
34
|
+
var ROLES = /^(button|link|tab|menuitem|menuitemcheckbox|menuitemradio|checkbox|radio|switch|option|combobox|slider|treeitem)$/;
|
|
35
|
+
|
|
36
|
+
function walk(root, out) {
|
|
37
|
+
var kids = root.children;
|
|
38
|
+
for (var i = 0; i < kids.length; i++) visit(kids[i], out);
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
function visit(el, out) {
|
|
42
|
+
if (el.id === ID && el === host && (!skip || skip.checked)) return;
|
|
43
|
+
if (!(host && el.getRootNode() === host.shadowRoot && (!panel.contains(el) || (logList && logList.contains(el))))) out.push(el);
|
|
44
|
+
if (el.shadowRoot) return walk(el.shadowRoot, out);
|
|
45
|
+
if (el.tagName === "SLOT" && el.assignedElements) {
|
|
46
|
+
var got = el.assignedElements({ flatten: true });
|
|
47
|
+
if (got.length) {
|
|
48
|
+
for (var i = 0; i < got.length; i++) visit(got[i], out);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
walk(el, out);
|
|
53
|
+
}
|
|
54
|
+
function shown(el) {
|
|
55
|
+
if (el.checkVisibility) return el.checkVisibility({ visibilityProperty: true, opacityProperty: false });
|
|
56
|
+
var s = getComputedStyle(el);
|
|
57
|
+
return s.display !== "none" && s.visibility !== "hidden" && el.getClientRects().length > 0;
|
|
58
|
+
}
|
|
59
|
+
function tabbable(el) {
|
|
60
|
+
if (!el.matches(FOCUSABLE)) return false;
|
|
61
|
+
if (el.tabIndex < 0 || el.matches(":disabled") || el.closest("[inert]")) return false;
|
|
62
|
+
if (el.tagName === "INPUT" && el.type === "hidden") return false;
|
|
63
|
+
if (el.tagName === "SUMMARY" && (!el.parentElement || el.parentElement.tagName !== "DETAILS" || el.parentElement.querySelector("summary") !== el)) return false;
|
|
64
|
+
return shown(el);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var stops = [], stopSet = new Set(), upSet = new Set(), missed = [], forced = [], forcedBad = [], domAt = new Map();
|
|
68
|
+
var GROUP = "[role=tablist],[role=menu],[role=menubar],[role=listbox],[role=radiogroup],[role=grid],[role=treegrid],[role=tree],[role=toolbar]";
|
|
69
|
+
var ITEM = /^(tab|menuitem|menuitemcheckbox|menuitemradio|option|radio|gridcell|row|treeitem)$/;
|
|
70
|
+
function nearTab(el) {
|
|
71
|
+
for (var p = el.parentElement; p; p = p.parentElement) if (stopSet.has(p)) return true;
|
|
72
|
+
return upSet.has(el);
|
|
73
|
+
}
|
|
74
|
+
function roving(el) {
|
|
75
|
+
var g = el.closest(GROUP);
|
|
76
|
+
if (!g || (!ITEM.test(el.getAttribute("role") || "") && !(el.hasAttribute("tabindex") && el.tabIndex < 0))) return false;
|
|
77
|
+
if (stopSet.has(g) || upSet.has(g)) return true;
|
|
78
|
+
var id = g.id;
|
|
79
|
+
return !!id && stops.some(function (s) { return (" " + (s.getAttribute("aria-controls") || "") + " " + (s.getAttribute("aria-owns") || "") + " ").indexOf(" " + id + " ") >= 0; });
|
|
80
|
+
}
|
|
81
|
+
function modal() {
|
|
82
|
+
try {
|
|
83
|
+
var l = document.querySelectorAll("dialog:modal");
|
|
84
|
+
return l.length ? l[l.length - 1] : null;
|
|
85
|
+
} catch (e) { return null; }
|
|
86
|
+
}
|
|
87
|
+
function within(m, e) {
|
|
88
|
+
for (var n = e; n; n = n.parentNode || n.host) if (n === m) return true;
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
function scan() {
|
|
92
|
+
var all = walk(document, []);
|
|
93
|
+
var top = modal();
|
|
94
|
+
if (top) all = all.filter(function (e) { return within(top, e); });
|
|
95
|
+
var found = all.filter(tabbable);
|
|
96
|
+
var groups = new Map();
|
|
97
|
+
found = found.filter(function (el) {
|
|
98
|
+
if (el.tagName !== "INPUT" || el.type !== "radio" || !el.name) return true;
|
|
99
|
+
var own = el.form || el.getRootNode(), byName = groups.get(own) || {};
|
|
100
|
+
groups.set(own, byName);
|
|
101
|
+
var g = byName[el.name] || (byName[el.name] = found.filter(function (x) { return x.tagName === "INPUT" && x.type === "radio" && x.name === el.name && (x.form || x.getRootNode()) === own; }));
|
|
102
|
+
var picked = g.filter(function (x) { return x.checked; })[0] || g[0];
|
|
103
|
+
return picked === el;
|
|
104
|
+
});
|
|
105
|
+
forced = found.filter(function (el) { return el.tabIndex > 0 && !(host && el.getRootNode() === host.shadowRoot); });
|
|
106
|
+
stops = ordered(document, found, null);
|
|
107
|
+
domAt = new Map();
|
|
108
|
+
forced.forEach(function (f) { domAt.set(f, forced.length > 30 ? found.indexOf(f) : ordered(document, found, f).indexOf(f)); });
|
|
109
|
+
forcedBad = forced.filter(function (f) { return domAt.get(f) !== stops.indexOf(f); });
|
|
110
|
+
stopSet = new Set(stops);
|
|
111
|
+
upSet = new Set();
|
|
112
|
+
stops.forEach(function (s) {
|
|
113
|
+
for (var p = s.parentElement; p && !upSet.has(p); p = p.parentElement) upSet.add(p);
|
|
114
|
+
});
|
|
115
|
+
var ids = document.querySelectorAll("[id='" + ID + "']"), only = !ids.length || (ids.length === 1 && ids[0] === host);
|
|
116
|
+
var miss = all.filter(function (el) {
|
|
117
|
+
if (stopSet.has(el) || (only ? el === host : el.closest("#" + ID)) || (host && el.getRootNode() === host.shadowRoot)) return false;
|
|
118
|
+
var t = el.tagName;
|
|
119
|
+
if (t === "HTML" || t === "BODY" || t === "LABEL" || t === "OPTION" || t === "OPTGROUP") return false;
|
|
120
|
+
var role = el.getAttribute("role") || "";
|
|
121
|
+
var looks = el.hasAttribute("onclick") || ROLES.test(role);
|
|
122
|
+
var s = getComputedStyle(el);
|
|
123
|
+
if (s.pointerEvents === "none") return false;
|
|
124
|
+
if (!looks) {
|
|
125
|
+
if (s.cursor !== "pointer") return false;
|
|
126
|
+
var ps = el.parentElement && getComputedStyle(el.parentElement);
|
|
127
|
+
if (ps && ps.cursor === "pointer") return false;
|
|
128
|
+
}
|
|
129
|
+
if (el.closest("label") || el.matches(":disabled") || el.closest("[inert]") || el.closest("[aria-disabled='true']")) return false;
|
|
130
|
+
if (!shown(el)) return false;
|
|
131
|
+
var r = el.getBoundingClientRect();
|
|
132
|
+
if (r.width < 8 || r.height < 8) return false;
|
|
133
|
+
return !nearTab(el) && !roving(el);
|
|
134
|
+
});
|
|
135
|
+
var missSet = new Set(miss);
|
|
136
|
+
missed = miss.filter(function (el) {
|
|
137
|
+
for (var p = el.parentElement; p; p = p.parentElement) if (missSet.has(p)) return false;
|
|
138
|
+
return true;
|
|
139
|
+
});
|
|
140
|
+
hoverScan();
|
|
141
|
+
}
|
|
142
|
+
function ordered(scope, list, flat) {
|
|
143
|
+
var units = [], groups = new Map(), out = [];
|
|
144
|
+
list.forEach(function (el) {
|
|
145
|
+
var h = el;
|
|
146
|
+
while (h.getRootNode() !== scope && h.getRootNode().host) h = h.getRootNode().host;
|
|
147
|
+
if (h === el) return units.push({ k: el === flat ? 0 : el.tabIndex, el: el });
|
|
148
|
+
var g = groups.get(h);
|
|
149
|
+
if (!g) {
|
|
150
|
+
g = { k: h.hasAttribute("tabindex") && h !== flat ? Math.max(h.tabIndex, 0) : 0, host: h, els: [] };
|
|
151
|
+
groups.set(h, g);
|
|
152
|
+
units.push(g);
|
|
153
|
+
}
|
|
154
|
+
g.els.push(el);
|
|
155
|
+
});
|
|
156
|
+
units.filter(function (u) { return u.k > 0; }).sort(function (a, b) { return a.k - b.k; }).concat(units.filter(function (u) { return u.k <= 0; })).forEach(function (u) {
|
|
157
|
+
if (u.host) out = out.concat(ordered(u.host.shadowRoot, u.els, flat));
|
|
158
|
+
else out.push(u.el);
|
|
159
|
+
});
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
var hovers = [], hoverOk = [], hovRule = new Map(), hovSeen = new Set(), hovHid = new Map(), tabOpens = new WeakSet();
|
|
163
|
+
function hoverTry(s) {
|
|
164
|
+
var hit = false;
|
|
165
|
+
hovers.forEach(function (h) {
|
|
166
|
+
var e = hovHid.get(h);
|
|
167
|
+
if (e && within(h, s) && !within(e, s) && !hiddenNow(e)) {
|
|
168
|
+
tabOpens.add(h);
|
|
169
|
+
hit = true;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
if (hit) rescan();
|
|
173
|
+
}
|
|
174
|
+
var HOVER = ":hover", FOC = ":focus-within|:focus-visible|:focus";
|
|
175
|
+
function parts(sel) {
|
|
176
|
+
var out = [], depth = 0, start = 0;
|
|
177
|
+
for (var i = 0; i < sel.length; i++) {
|
|
178
|
+
var ch = sel.charAt(i);
|
|
179
|
+
if (ch === "(") depth++;
|
|
180
|
+
else if (ch === ")") depth--;
|
|
181
|
+
else if (ch === "," && !depth) { out.push(sel.slice(start, i).trim()); start = i + 1; }
|
|
182
|
+
}
|
|
183
|
+
out.push(sel.slice(start).trim());
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
186
|
+
function bare(sel, re) {
|
|
187
|
+
return sel.replace(new RegExp("(^|[\\s>+~(])(" + re + ")", "g"), "$1*").replace(new RegExp(re, "g"), "");
|
|
188
|
+
}
|
|
189
|
+
function reveals(st) {
|
|
190
|
+
var d = st.getPropertyValue("display"), v = st.getPropertyValue("visibility"), o = st.getPropertyValue("opacity"), mh = st.getPropertyValue("max-height");
|
|
191
|
+
return (d !== "" && d !== "none") || v === "visible" || (o !== "" && parseFloat(o) > 0) || (mh !== "" && mh !== "0" && mh !== "0px");
|
|
192
|
+
}
|
|
193
|
+
var cssRules = 0, cssSheets = 0, cssBlocked = [];
|
|
194
|
+
function nest(sel, up) {
|
|
195
|
+
if (!up) return sel;
|
|
196
|
+
return parts(sel).map(function (q) { return q.indexOf("&") >= 0 ? q.split("&").join(":is(" + up + ")") : ":is(" + up + ") " + q; }).join(", ");
|
|
197
|
+
}
|
|
198
|
+
function depth(p, k) {
|
|
199
|
+
var d = 0;
|
|
200
|
+
for (var i = 0; i < k; i++) {
|
|
201
|
+
var ch = p.charAt(i);
|
|
202
|
+
if (ch === "\\") i++;
|
|
203
|
+
else if (ch === "(") d++;
|
|
204
|
+
else if (ch === ")") d--;
|
|
205
|
+
}
|
|
206
|
+
return d;
|
|
207
|
+
}
|
|
208
|
+
function compound(p, k) {
|
|
209
|
+
var d = 0, i = k - 1;
|
|
210
|
+
for (; i >= 0; i--) {
|
|
211
|
+
var ch = p.charAt(i);
|
|
212
|
+
if (i > 0 && p.charAt(i - 1) === "\\") {
|
|
213
|
+
i--;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (ch === ")") d++;
|
|
217
|
+
else if (ch === "(") {
|
|
218
|
+
if (!d) break;
|
|
219
|
+
d--;
|
|
220
|
+
} else if (!d && /[\s>+~,]/.test(ch)) break;
|
|
221
|
+
}
|
|
222
|
+
var c = p.slice(i + 1, k).trim();
|
|
223
|
+
return c ? bare(c, HOVER) : "";
|
|
224
|
+
}
|
|
225
|
+
function selfFocus(p) {
|
|
226
|
+
var m = p.match(new RegExp(FOC)), k = m ? m.index + m[0].length : -1;
|
|
227
|
+
if (k < 0 || depth(p, k)) return false;
|
|
228
|
+
for (var d = 0; k < p.length; k++) {
|
|
229
|
+
var ch = p.charAt(k);
|
|
230
|
+
if (ch === "\\") k++;
|
|
231
|
+
else if (ch === "(") d++;
|
|
232
|
+
else if (ch === ")") d--;
|
|
233
|
+
else if (!d && /[\s>+~]/.test(ch)) return false;
|
|
234
|
+
}
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
var sheetMemo = new WeakMap();
|
|
238
|
+
function readRules() {
|
|
239
|
+
var hov = [], foc = [];
|
|
240
|
+
cssRules = 0;
|
|
241
|
+
cssSheets = 0;
|
|
242
|
+
cssBlocked = [];
|
|
243
|
+
function take(sel, src) {
|
|
244
|
+
parts(sel).forEach(function (p) {
|
|
245
|
+
if (/:focus/.test(p)) return foc.push([bare(p, FOC), selfFocus(p)]);
|
|
246
|
+
var k = p.indexOf(HOVER), on;
|
|
247
|
+
if (k < 0) return;
|
|
248
|
+
if (depth(p, k)) on = compound(p, k);
|
|
249
|
+
else {
|
|
250
|
+
var pre = p.slice(0, k);
|
|
251
|
+
if (!pre.trim() || /[\s>+~]$/.test(pre)) return;
|
|
252
|
+
on = bare(pre, HOVER);
|
|
253
|
+
}
|
|
254
|
+
if (on) hov.push([bare(p, HOVER), on, p, src]);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function go(list, src, up) {
|
|
258
|
+
for (var i = 0; i < list.length; i++) {
|
|
259
|
+
var r = list[i], sel = up, st = null;
|
|
260
|
+
if (r.selectorText !== undefined) {
|
|
261
|
+
sel = nest(r.selectorText, up);
|
|
262
|
+
st = r.style;
|
|
263
|
+
} else if (up && r.style && !r.cssRules) st = r.style;
|
|
264
|
+
if (st) {
|
|
265
|
+
cssRules++;
|
|
266
|
+
if (/:hover|:focus/.test(sel) && reveals(st)) take(sel, src);
|
|
267
|
+
}
|
|
268
|
+
if (r.cssRules && r.cssRules.length) go(r.cssRules, src, sel);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
var sheets = Array.prototype.slice.call(document.styleSheets).concat(document.adoptedStyleSheets || []);
|
|
272
|
+
sheets.forEach(function (sh) {
|
|
273
|
+
var list;
|
|
274
|
+
try { list = sh.cssRules; } catch (e) { return cssBlocked.push(sh.href || "a style sheet"); }
|
|
275
|
+
var memo = sheetMemo.get(sh);
|
|
276
|
+
if (!memo || memo.list !== list || memo.n !== list.length || memo.node !== sh.ownerNode) {
|
|
277
|
+
var h0 = hov, f0 = foc, c0 = cssRules;
|
|
278
|
+
hov = [];
|
|
279
|
+
foc = [];
|
|
280
|
+
cssRules = 0;
|
|
281
|
+
try { go(list, sh.href || (sh.ownerNode ? "an inline <style> in the page" : "a style sheet added by script"), ""); } catch (e) {
|
|
282
|
+
hov = h0;
|
|
283
|
+
foc = f0;
|
|
284
|
+
cssRules = c0;
|
|
285
|
+
return cssBlocked.push(sh.href || "a style sheet");
|
|
286
|
+
}
|
|
287
|
+
memo = { list: list, n: list.length, node: sh.ownerNode, hov: hov, foc: foc, rules: cssRules };
|
|
288
|
+
sheetMemo.set(sh, memo);
|
|
289
|
+
hov = h0;
|
|
290
|
+
foc = f0;
|
|
291
|
+
cssRules = c0;
|
|
292
|
+
}
|
|
293
|
+
hov = hov.concat(memo.hov);
|
|
294
|
+
foc = foc.concat(memo.foc);
|
|
295
|
+
cssRules += memo.rules;
|
|
296
|
+
cssSheets++;
|
|
297
|
+
});
|
|
298
|
+
return [hov, foc];
|
|
299
|
+
}
|
|
300
|
+
function hiddenNow(e) {
|
|
301
|
+
return !shown(e) || getComputedStyle(e).opacity === "0" || e.getBoundingClientRect().height < 1;
|
|
302
|
+
}
|
|
303
|
+
function hoverScan() {
|
|
304
|
+
var rr = readRules(), foc = rr[1], found = [], seenH = new Set(), ok = [], top = modal();
|
|
305
|
+
hovRule = new Map();
|
|
306
|
+
hovSeen = new Set();
|
|
307
|
+
rr[0].forEach(function (h) {
|
|
308
|
+
var list;
|
|
309
|
+
try { list = document.querySelectorAll(h[0]); } catch (e) { return; }
|
|
310
|
+
for (var i = 0; i < list.length; i++) {
|
|
311
|
+
var e = list[i], host = null;
|
|
312
|
+
if (!hiddenNow(e) || (!e.matches(FOCUSABLE) && !e.querySelector(FOCUSABLE))) continue;
|
|
313
|
+
try { host = e.parentElement && e.parentElement.closest(h[1]); } catch (x) {}
|
|
314
|
+
if (!host || host === document.body || host === document.documentElement || seenH.has(host) || !shown(host) || (top && !within(top, host))) continue;
|
|
315
|
+
if (host.matches("[aria-expanded],[aria-haspopup]") || host.querySelector("[aria-expanded],[aria-haspopup]")) {
|
|
316
|
+
ok.push([host, "toggle"]);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (foc.some(function (f) { try { return (!f[1] || shown(e)) && e.matches(f[0]); } catch (x) { return false; } })) {
|
|
320
|
+
ok.push([host, "focus"]);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (tabOpens.has(host)) {
|
|
324
|
+
ok.push([host, "tab"]);
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
found.push(host);
|
|
328
|
+
seenH.add(host);
|
|
329
|
+
hovHid.set(host, e);
|
|
330
|
+
hovRule.set(host, [h[2], h[3]]);
|
|
331
|
+
if (shown(e) && stops.some(function (s) { return e.contains(s); })) hovSeen.add(host);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
hovers = found;
|
|
335
|
+
hoverOk = ok.filter(function (o) { return !seenH.has(o[0]); });
|
|
336
|
+
}
|
|
337
|
+
scan();
|
|
338
|
+
|
|
339
|
+
var host = document.createElement("div");
|
|
340
|
+
host.id = ID;
|
|
341
|
+
host.style.cssText = "all:initial;position:absolute;left:0;top:0;width:0;height:0;overflow:visible;z-index:2147483647;pointer-events:none;";
|
|
342
|
+
var root = host.attachShadow({ mode: "open" });
|
|
343
|
+
var style = document.createElement("style");
|
|
344
|
+
style.textContent = [
|
|
345
|
+
":host{all:initial}",
|
|
346
|
+
"svg{position:fixed;inset:0;width:100vw;height:100vh;overflow:visible}",
|
|
347
|
+
"svg.pg{position:absolute;left:0;top:0;width:1px;height:1px;overflow:visible}",
|
|
348
|
+
".p{position:fixed;bottom:66px;right:66px;width:350px;box-sizing:border-box;padding:6px;background:#e4dccd;color:#1a1612;border-radius:16px;box-shadow:0 1px 2px rgba(0,0,0,.12),0 14px 34px rgba(0,0,0,.26);font:14px/1.45 -apple-system,system-ui,'Segoe UI',Roboto,sans-serif;pointer-events:auto;cursor:grab;overflow-x:hidden;overflow-y:auto;max-height:calc(100vh - 90px);overscroll-behavior:contain}",
|
|
349
|
+
".tb{display:flex;align-items:center;gap:4px;padding:0 0 5px 4px}",
|
|
350
|
+
".t{margin:0;flex:1;white-space:nowrap;font:700 17px/1.2 Georgia,serif;letter-spacing:-.01em}",
|
|
351
|
+
".cd{margin:4px 0 0;padding:7px 10px;background:#fbf8f3;border-radius:10px}",
|
|
352
|
+
".tb+.cd{margin-top:0}",
|
|
353
|
+
".p.rm{padding:10px}",
|
|
354
|
+
".rm .tb{gap:6px;padding:4px 2px 8px 6px}",
|
|
355
|
+
".rm .t{font-size:19px}",
|
|
356
|
+
".rm .cd{margin-top:6px;padding:12px 14px}",
|
|
357
|
+
".rm .tb+.cd{margin-top:0}",
|
|
358
|
+
".rm .ta{height:32px;padding:0 12px 0 10px}",
|
|
359
|
+
".rm .n{gap:7px;margin-top:12px}",
|
|
360
|
+
".rm .n b{font-size:22px}",
|
|
361
|
+
".rm .k{margin-top:7px}",
|
|
362
|
+
".rm .x,.rm .b.cn{width:32px;height:32px}",
|
|
363
|
+
".rm .sec{margin-top:6px}",
|
|
364
|
+
".rm .sg{min-height:46px;padding:0 12px 0 8px}",
|
|
365
|
+
".rm .ic{width:30px;height:30px;border-radius:8px}",
|
|
366
|
+
".rm .so,.rm .lbd,.rm .la{padding:2px 14px 14px}",
|
|
367
|
+
".rm .hw{margin:10px 6px 2px}",
|
|
368
|
+
".rm .m{margin-top:8px;gap:6px}",
|
|
369
|
+
".rm .c{padding:6px 10px}",
|
|
370
|
+
".rm .pr{margin-top:12px}",
|
|
371
|
+
".rm .pl{height:30px;padding:0 14px 0 11px}",
|
|
372
|
+
".rm .b{width:30px;height:30px}",
|
|
373
|
+
".rm .lf{margin-top:10px}",
|
|
374
|
+
".rm .lt{padding:3px 9px}",
|
|
375
|
+
".rm .ll{margin:10px -14px 0}",
|
|
376
|
+
".rm .lx{padding:6px 14px}",
|
|
377
|
+
".rm .lr.lb2{gap:6px;margin-top:12px}",
|
|
378
|
+
".rm .kl,.rm .ka{height:38px;border-radius:8px}",
|
|
379
|
+
".rm .lnt{height:38px;border-radius:8px}",
|
|
380
|
+
".rm .lck,.rm .lw,.rm .sm,.rm .lr{margin-top:10px}",
|
|
381
|
+
".rm .lrt{margin-top:0}",
|
|
382
|
+
".rm .gp .k,.rm .lgp .k{margin-top:10px}",
|
|
383
|
+
".rm .mn{margin-top:12px}",
|
|
384
|
+
".rm .so>.k:first-child,.rm .lbd>:first-child,.rm .la>:first-child,.rm .cd>:first-child,.rm .cd>div:first-child>:first-child{margin-top:0}",
|
|
385
|
+
".cd>:first-child,.cd>div:first-child>:first-child{margin-top:0}",
|
|
386
|
+
".cd>div:empty{display:none}",
|
|
387
|
+
".ta{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px 0 8px;border:1.5px solid #1a1612;border-radius:999px;background:#fbf8f3;font-weight:700;font-size:14px;white-space:nowrap;cursor:pointer;flex:none}",
|
|
388
|
+
".ta:hover{background:#fff}",
|
|
389
|
+
".ta:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
390
|
+
".n{display:flex;align-items:baseline;gap:6px;margin:5px 0 0}",
|
|
391
|
+
".n b{font:700 20px/1 -apple-system,system-ui,'Segoe UI',Roboto,sans-serif;letter-spacing:-.02em;font-variant-numeric:tabular-nums}",
|
|
392
|
+
".k{display:flex;align-items:center;gap:10px;margin:4px 0 0;font-size:14px}",
|
|
393
|
+
".d{width:16px;height:16px;border-radius:50%;background:#1a1612;box-shadow:0 0 0 2px #fff inset,0 0 0 1px #1a1612;flex:none}",
|
|
394
|
+
".r{width:16px;height:12px;box-sizing:border-box;border:2px dashed #d0103a;border-radius:2px;background:rgba(208,16,58,.12);flex:none}",
|
|
395
|
+
".x{width:28px;height:28px;flex:none;padding:0;border:0;border-radius:50%;background:transparent;color:#1a1612;cursor:pointer;display:grid;place-items:center}",
|
|
396
|
+
".p svg{display:block;position:static;inset:auto;width:auto;height:auto;overflow:hidden;flex:none}",
|
|
397
|
+
".x:hover{background:rgba(26,22,18,.08)}",
|
|
398
|
+
".b.cn{width:28px;height:28px}",
|
|
399
|
+
".sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}",
|
|
400
|
+
".x:focus-visible,.a:focus-visible,.sg:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
401
|
+
".sec{margin:4px 0 0;background:#fbf8f3;border-radius:10px}",
|
|
402
|
+
".sg{all:unset;box-sizing:border-box;display:flex;align-items:center;gap:10px;width:100%;min-height:32px;padding:0 9px 0 5px;border-radius:10px;font-weight:700;font-size:14px;cursor:pointer}",
|
|
403
|
+
".sg:hover{background:#fff}",
|
|
404
|
+
".ic{width:22px;height:22px;border-radius:6px;background:#efe8dc;display:grid;place-items:center;flex:none}",
|
|
405
|
+
".sg[aria-expanded=true] .ic{background:#1a1612;color:#fbf8f3}",
|
|
406
|
+
".warn .ic{background:rgba(208,16,58,.12);color:#d0103a}",
|
|
407
|
+
".warn .sg[aria-expanded=true] .ic{background:#d0103a;color:#fff}",
|
|
408
|
+
".bg{margin-left:auto;padding:2px 8px;border-radius:999px;background:#d0103a;color:#fff;font-weight:700;line-height:1.3}",
|
|
409
|
+
".bg:empty{display:none}",
|
|
410
|
+
".bg:not(:empty)+i{margin-left:12px}",
|
|
411
|
+
".sg i{margin-left:auto;width:7px;height:7px;border-right:2px solid #1a1612;border-bottom:2px solid #1a1612;transform:translate(-3px,-2px) rotate(45deg)}",
|
|
412
|
+
".sg[aria-expanded=true] i{transform:translate(-3px,2px) rotate(225deg)}",
|
|
413
|
+
".so,.lbd,.la{padding:1px 10px 8px}",
|
|
414
|
+
".lbd{overflow:hidden}",
|
|
415
|
+
".so>.k:first-child,.lbd>:first-child,.la>:first-child{margin-top:0}",
|
|
416
|
+
".so[hidden]{display:none}",
|
|
417
|
+
".hw{margin:5px 4px 0;color:#5f564c;font-size:11px;line-height:1.3;font-weight:600}",
|
|
418
|
+
".a{color:#5f564c;font-size:13px;font-weight:400;text-decoration:none;white-space:nowrap}",
|
|
419
|
+
".vr{float:right;margin-left:8px;color:#5f564c;font-weight:400}",
|
|
420
|
+
".hw+.hw{margin-top:4px}",
|
|
421
|
+
".mn{margin:6px 0 0;color:#1e3a8a}",
|
|
422
|
+
".a:hover{color:#9a3412;text-decoration:underline}",
|
|
423
|
+
".p.g{cursor:grabbing;user-select:none}",
|
|
424
|
+
".n b.e{color:#d0103a}",
|
|
425
|
+
".n b.ok{color:#1f7a3f}",
|
|
426
|
+
".s{cursor:pointer}",
|
|
427
|
+
"svg.in{z-index:1}",
|
|
428
|
+
"g.o{pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none}",
|
|
429
|
+
".s input{width:16px;height:16px;margin:0 2px 0 1px;accent-color:#c2410c;cursor:pointer}",
|
|
430
|
+
".s.off{opacity:.45;cursor:default}",
|
|
431
|
+
".s.off input{cursor:default}",
|
|
432
|
+
".s input:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
433
|
+
".h{width:16px;height:16px;border-radius:50%;background:#fff;border:2px dashed #1a1612;box-sizing:border-box;flex:none}",
|
|
434
|
+
".m{list-style:none;margin:5px 0 0;padding:2px;display:flex;flex-wrap:wrap;gap:4px}",
|
|
435
|
+
".c{all:unset;font:inherit;font-size:14px;line-height:1;cursor:pointer;padding:4px 8px;border:1px dashed #d0103a;border-radius:999px;background:rgba(208,16,58,.06);color:#1a1612}",
|
|
436
|
+
".c:hover{background:rgba(208,16,58,.14)}",
|
|
437
|
+
".c[aria-pressed=true]{border-style:solid;background:#d0103a;color:#fff}",
|
|
438
|
+
".c:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
439
|
+
".gp[hidden]{display:none}",
|
|
440
|
+
".gp .k,.lgp .k{margin:6px 0 0}",
|
|
441
|
+
".w{display:flex;align-items:center;gap:8px;margin:0;font-size:14px}",
|
|
442
|
+
".w span{flex:1;font-variant-numeric:tabular-nums}",
|
|
443
|
+
".b{all:unset;box-sizing:border-box;width:28px;height:28px;border:1.5px solid #1a1612;border-radius:50%;display:grid;place-items:center;cursor:pointer;color:#1a1612;flex:none}",
|
|
444
|
+
".b:hover{background:rgba(26,22,18,.08)}",
|
|
445
|
+
".b:disabled{opacity:.3;cursor:default;background:none}",
|
|
446
|
+
".b:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
447
|
+
".pr{display:flex;align-items:center;gap:10px;margin:6px 0 0;font-size:14px;color:#5f564c}",
|
|
448
|
+
".pr+.pr{margin-top:8px}",
|
|
449
|
+
".pr .lo{display:inline-flex;align-items:center;height:30px;color:#1a1612}",
|
|
450
|
+
".sm{margin:6px 0 0;font-size:14px;line-height:1.45}",
|
|
451
|
+
".sm[hidden]{display:none}",
|
|
452
|
+
".sm .g{color:#1f7a3f;font-weight:600}",
|
|
453
|
+
".sm .e{color:#d0103a;font-weight:700}",
|
|
454
|
+
".sm .q{color:#5f564c;font-weight:400}",
|
|
455
|
+
".m .mo{align-self:center;color:#5f564c;font-size:14px}",
|
|
456
|
+
".pl{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;height:28px;padding:0 13px 0 10px;border-radius:999px;background:#1a1612;color:#f7f3ec;font-weight:700;font-size:14px;cursor:pointer;flex:none}",
|
|
457
|
+
".pl:hover{background:#3a332c}",
|
|
458
|
+
".pl:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
459
|
+
".ls{font-weight:400;color:#5f564c}",
|
|
460
|
+
".lv{color:#d0103a;font-weight:700}",
|
|
461
|
+
".lbd[hidden],.la[hidden],.lm[hidden]{display:none}",
|
|
462
|
+
".lf{display:grid;grid-template-columns:1fr 1fr;gap:2px;margin:6px 0 0;padding:3px;background:#efe8dc;border-radius:10px}",
|
|
463
|
+
".lt{all:unset;box-sizing:border-box;text-align:center;padding:2px 9px;border-radius:7px;color:#5f564c;font-weight:600;font-size:14px;line-height:1.3;cursor:pointer}",
|
|
464
|
+
".lt:hover{color:#1a1612;background:rgba(26,22,18,.06)}",
|
|
465
|
+
".lt[aria-pressed=true]{background:#fff;color:#1a1612;box-shadow:0 1px 2px rgba(26,22,18,.2)}",
|
|
466
|
+
".lt.e{color:#d0103a}",
|
|
467
|
+
".lt.e:hover{background:rgba(208,16,58,.1)}",
|
|
468
|
+
".lt.e[aria-pressed=true]{background:#d0103a;color:#fff}",
|
|
469
|
+
".ll{list-style:none;margin:6px -10px 0;padding:0;cursor:auto}",
|
|
470
|
+
".lx{padding:3px 10px}",
|
|
471
|
+
".lx.bad{background:rgba(208,16,58,.07)}",
|
|
472
|
+
".lx .tm{margin-right:8px;font:500 14px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#5f564c}",
|
|
473
|
+
".lx .st{font:700 14px/1.4 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}",
|
|
474
|
+
".lx .bd{display:block}",
|
|
475
|
+
".ok .st{color:#1f7a3f}.bad .st{color:#d0103a}.skip .st{color:#5f564c}.info .st{color:#1e3a8a}",
|
|
476
|
+
".ft{color:#1e3a8a}.bad .ft{color:#d0103a}",
|
|
477
|
+
".lc{all:unset;box-sizing:border-box;display:inline-block;min-width:22px;padding:0 6px;border:1px dashed #1a1612;border-radius:999px;font-size:14px;line-height:1.4;text-align:center;cursor:pointer}",
|
|
478
|
+
".lc:hover{background:rgba(26,22,18,.08)}",
|
|
479
|
+
".lr{display:flex;flex-wrap:wrap;gap:8px;margin:6px 0 0}",
|
|
480
|
+
".lrt{margin:0}",
|
|
481
|
+
".lr.lb2{display:grid;grid-template-columns:1fr 1fr;gap:5px;margin-top:8px}",
|
|
482
|
+
".kl,.ka{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:7px;height:30px;border-radius:7px;font-weight:700;font-size:14px;white-space:nowrap;cursor:pointer}",
|
|
483
|
+
".kl{border:1.5px solid #1a1612;background:#fff;color:#1a1612}",
|
|
484
|
+
".kl:hover{background:#efe8dc}",
|
|
485
|
+
".ka{background:#1a1612;color:#fbf8f3}",
|
|
486
|
+
".ka:hover{background:#3a332c}",
|
|
487
|
+
".kl:focus-visible,.ka:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
488
|
+
".lnt{all:unset;box-sizing:border-box;display:flex;align-items:center;justify-content:center;gap:7px;width:100%;height:30px;border:1.5px dashed #1a1612;border-radius:7px;font-weight:700;font-size:14px;cursor:pointer}",
|
|
489
|
+
".lnt:hover{border-style:solid;background:#fff}",
|
|
490
|
+
".lnt:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
491
|
+
".lk{all:unset;box-sizing:border-box;padding:5px 13px;border-radius:999px;background:#1a1612;color:#f7f3ec;font-weight:700;font-size:14px;cursor:pointer}",
|
|
492
|
+
".lk:hover{background:#3a332c}",
|
|
493
|
+
".lo{all:unset;box-sizing:border-box;padding:4px 12px;border:1.5px solid #1a1612;border-radius:999px;font-weight:600;font-size:14px;cursor:pointer}",
|
|
494
|
+
".lo:hover{background:rgba(26,22,18,.08)}",
|
|
495
|
+
".lt:focus-visible,.lc:focus-visible,.lk:focus-visible,.lo:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
496
|
+
".la p,.lm{margin:8px 0 0}",
|
|
497
|
+
".lck{margin:6px 0 0;font-size:14px;line-height:1.45}",
|
|
498
|
+
".lck[hidden]{display:none}",
|
|
499
|
+
".lq{color:#1e3a8a;font-weight:700;text-decoration:none}",
|
|
500
|
+
".lq:hover{text-decoration:underline;text-underline-offset:2px}",
|
|
501
|
+
".lq.bad{color:#d0103a}",
|
|
502
|
+
".lq:focus-visible{outline:3px solid #c2410c;outline-offset:2px;border-radius:2px}",
|
|
503
|
+
".wc{color:#1f7a3f;font-weight:400}",
|
|
504
|
+
".nw .wc{display:none}",
|
|
505
|
+
".lw{display:flex;align-items:center;gap:8px;margin:6px 0 0;font-size:14px;color:#1f7a3f;cursor:pointer}",
|
|
506
|
+
".lw input{width:16px;height:16px;margin:0 2px 0 1px;accent-color:#c2410c;cursor:pointer}",
|
|
507
|
+
".lw input:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
508
|
+
".lm{color:#d0103a}"
|
|
509
|
+
].join("");
|
|
510
|
+
try {
|
|
511
|
+
var sheet = new CSSStyleSheet();
|
|
512
|
+
sheet.replaceSync(style.textContent);
|
|
513
|
+
root.adoptedStyleSheets = [sheet];
|
|
514
|
+
} catch (e) {
|
|
515
|
+
root.appendChild(style);
|
|
516
|
+
}
|
|
517
|
+
var spot = document.createElementNS(NS, "svg");
|
|
518
|
+
root.appendChild(spot);
|
|
519
|
+
var underPg = document.createElementNS(NS, "svg");
|
|
520
|
+
underPg.setAttribute("class", "pg");
|
|
521
|
+
root.appendChild(underPg);
|
|
522
|
+
var svgPg = document.createElementNS(NS, "svg");
|
|
523
|
+
svgPg.setAttribute("class", "pg");
|
|
524
|
+
root.appendChild(svgPg);
|
|
525
|
+
var under = document.createElementNS(NS, "svg");
|
|
526
|
+
root.appendChild(under);
|
|
527
|
+
var svg = document.createElementNS(NS, "svg");
|
|
528
|
+
root.appendChild(svg);
|
|
529
|
+
var dotPg = document.createElementNS(NS, "svg");
|
|
530
|
+
dotPg.setAttribute("class", "pg");
|
|
531
|
+
root.appendChild(dotPg);
|
|
532
|
+
var dot = document.createElementNS(NS, "svg");
|
|
533
|
+
root.appendChild(dot);
|
|
534
|
+
[spot, underPg, svgPg, under, svg, dotPg, dot].forEach(function (g) { g.setAttribute("aria-hidden", "true"); });
|
|
535
|
+
|
|
536
|
+
var panel = document.createElement("div");
|
|
537
|
+
panel.className = "p";
|
|
538
|
+
panel.setAttribute("role", "dialog");
|
|
539
|
+
panel.setAttribute("aria-label", "Tab trail");
|
|
540
|
+
function line(cls, bold, text, mark) {
|
|
541
|
+
var p = document.createElement("p");
|
|
542
|
+
p.className = cls;
|
|
543
|
+
if (mark) { var m = document.createElement("span"); m.className = mark; p.appendChild(m); }
|
|
544
|
+
if (bold !== null) { var b = document.createElement("b"); b.textContent = bold; p.appendChild(b); }
|
|
545
|
+
p.appendChild(document.createTextNode(text));
|
|
546
|
+
panel.appendChild(p);
|
|
547
|
+
return p;
|
|
548
|
+
}
|
|
549
|
+
var x = document.createElement("button");
|
|
550
|
+
x.className = "x";
|
|
551
|
+
x.type = "button";
|
|
552
|
+
x.setAttribute("aria-label", "Close Tab trail");
|
|
553
|
+
function icon(parent, w, d, sw) {
|
|
554
|
+
var g = el("svg", { width: w, height: w, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", "stroke-width": sw, "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, parent);
|
|
555
|
+
el("path", { d: d }, g);
|
|
556
|
+
return g;
|
|
557
|
+
}
|
|
558
|
+
icon(x, 16, "M3 3l10 10M13 3L3 13", 2);
|
|
559
|
+
var bar = document.createElement("div");
|
|
560
|
+
bar.className = "tb";
|
|
561
|
+
panel.appendChild(bar);
|
|
562
|
+
var corner = document.createElement("button");
|
|
563
|
+
corner.className = "b cn";
|
|
564
|
+
corner.type = "button";
|
|
565
|
+
corner.setAttribute("aria-label", "Move to the next corner");
|
|
566
|
+
corner.title = "Move to the next corner";
|
|
567
|
+
var cg = icon(corner, 16, "M5 11.5V5h6.5M9.5 3.2L11.5 5 9.5 6.8", 1.6);
|
|
568
|
+
el("rect", { x: 2, y: 2, width: 12, height: 12, rx: 2 }, cg);
|
|
569
|
+
el("rect", { x: 9.5, y: 9.5, width: 2, height: 2, fill: "currentColor" }, cg);
|
|
570
|
+
corner.addEventListener("click", function () {
|
|
571
|
+
var r = panel.getBoundingClientRect(), W = innerWidth, H = innerHeight;
|
|
572
|
+
var mx = Math.max(8, Math.min(66, (W - r.width) / 2)) + "px", my = Math.max(8, Math.min(66, (H - r.height) / 2)) + "px";
|
|
573
|
+
var right = r.left + r.width / 2 > W / 2, low = r.top + r.height / 2 > H / 2;
|
|
574
|
+
var k = !low && !right ? 1 : !low && right ? 2 : low && right ? 3 : 0;
|
|
575
|
+
for (var i = 0; i < 4; i++) {
|
|
576
|
+
var toRight = k === 1 || k === 2, toLow = k === 2 || k === 3;
|
|
577
|
+
panel.style.left = toRight ? "auto" : mx;
|
|
578
|
+
panel.style.right = toRight ? mx : "auto";
|
|
579
|
+
panel.style.top = toLow ? "auto" : my;
|
|
580
|
+
panel.style.bottom = toLow ? my : "auto";
|
|
581
|
+
var n = panel.getBoundingClientRect();
|
|
582
|
+
if (Math.abs(n.left - r.left) > 2 || Math.abs(n.top - r.top) > 2) break;
|
|
583
|
+
k = (k + 1) % 4;
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
var say = document.createElement("p");
|
|
587
|
+
say.className = "sr";
|
|
588
|
+
say.setAttribute("role", "status");
|
|
589
|
+
say.setAttribute("aria-live", "polite");
|
|
590
|
+
panel.appendChild(say);
|
|
591
|
+
var sayList = [], sayT = 0;
|
|
592
|
+
function announce(t) {
|
|
593
|
+
sayList.push(t);
|
|
594
|
+
if (sayT) return;
|
|
595
|
+
sayT = setTimeout(function () {
|
|
596
|
+
sayT = 0;
|
|
597
|
+
if (closed) return;
|
|
598
|
+
var text = sayList.join(" ");
|
|
599
|
+
sayList = [];
|
|
600
|
+
say.textContent = "";
|
|
601
|
+
setTimeout(function () { say.textContent = text; }, 50);
|
|
602
|
+
}, 1000);
|
|
603
|
+
}
|
|
604
|
+
bar.appendChild(line("t", null, "Tab trail"));
|
|
605
|
+
var playCard = document.createElement("div");
|
|
606
|
+
playCard.className = "cd";
|
|
607
|
+
panel.appendChild(playCard);
|
|
608
|
+
var playRow = document.createElement("p");
|
|
609
|
+
playRow.className = "pr";
|
|
610
|
+
var play = document.createElement("button");
|
|
611
|
+
play.className = "pl";
|
|
612
|
+
play.type = "button";
|
|
613
|
+
var playIcon = document.createElement("span");
|
|
614
|
+
play.appendChild(playIcon);
|
|
615
|
+
var playWord = document.createTextNode("Play");
|
|
616
|
+
play.appendChild(playWord);
|
|
617
|
+
play.addEventListener("mousedown", function (e) { e.preventDefault(); });
|
|
618
|
+
var playText = document.createElement("span");
|
|
619
|
+
playText.textContent = "Visits every stop for you";
|
|
620
|
+
playRow.appendChild(play);
|
|
621
|
+
playRow.appendChild(playText);
|
|
622
|
+
playCard.appendChild(playRow);
|
|
623
|
+
var AI_ICON = "M3.5 5.5h9v8h-9zM8 5.5V3.2M8 1.9v.1M6 8.6v1.1M10 8.6v1.1M6.3 11.6h3.4M1.8 8.5v2.6M14.2 8.5v2.6", COPY_ICON = "M10.5 5.5V3a.5.5 0 0 0-.5-.5H3a.5.5 0 0 0-.5.5v7a.5.5 0 0 0 .5.5h2.5M5.5 5.5h8v8h-8z";
|
|
624
|
+
var aiBtn = document.createElement("button");
|
|
625
|
+
aiBtn.className = "ta";
|
|
626
|
+
aiBtn.type = "button";
|
|
627
|
+
icon(aiBtn, 15, AI_ICON, 1.6);
|
|
628
|
+
aiBtn.appendChild(document.createTextNode("Copy for AI"));
|
|
629
|
+
aiBtn.addEventListener("click", function () { copyIt(aiBtn, window, aiText(), "Copy for AI"); });
|
|
630
|
+
bar.appendChild(aiBtn);
|
|
631
|
+
bar.appendChild(corner);
|
|
632
|
+
bar.appendChild(x);
|
|
633
|
+
var sumLine = document.createElement("p");
|
|
634
|
+
sumLine.className = "sm";
|
|
635
|
+
sumLine.hidden = true;
|
|
636
|
+
playCard.appendChild(sumLine);
|
|
637
|
+
var resCard = document.createElement("div");
|
|
638
|
+
resCard.className = "cd";
|
|
639
|
+
panel.appendChild(resCard);
|
|
640
|
+
var info = document.createElement("div");
|
|
641
|
+
resCard.appendChild(info);
|
|
642
|
+
var shownEl = null, chips = [], drawn = [], panelIn = false, pRet = null;
|
|
643
|
+
var KIND = { img: "Image", picture: "Image", svg: "Icon", i: "Icon", video: "Video", a: "Link", li: "List item", tr: "Table row", td: "Table cell" };
|
|
644
|
+
var BARE = { button: "Button", textarea: "Field", select: "Dropdown", iframe: "Frame" };
|
|
645
|
+
function kind(m, tag) {
|
|
646
|
+
if (tag === "input") return m.type === "checkbox" ? "Checkbox" : m.type === "radio" ? "Radio" : /^(submit|button|reset|image)$/.test(m.type) ? "Button" : "Field";
|
|
647
|
+
return KIND[tag] || BARE[tag] || "Clickable box";
|
|
648
|
+
}
|
|
649
|
+
function named(m) {
|
|
650
|
+
var by = m.getAttribute("aria-labelledby"), r = m.getRootNode(), t = "";
|
|
651
|
+
if (by && r.getElementById) t = by.split(/\s+/).map(function (id) { var x = r.getElementById(id); return x ? x.textContent : ""; }).join(" ");
|
|
652
|
+
if (!t.trim()) t = m.getAttribute("aria-label") || "";
|
|
653
|
+
if (!t.trim() && m.labels && m.labels.length) t = [].map.call(m.labels, function (l) { return l.innerText || l.textContent; }).join(" ");
|
|
654
|
+
if (!t.trim()) t = m.getAttribute("placeholder") || "";
|
|
655
|
+
if (!t.trim() && m.tagName === "INPUT" && /^(submit|button|reset)$/.test(m.type)) t = m.value;
|
|
656
|
+
if (!t.trim()) t = m.innerText || "";
|
|
657
|
+
if (!t.trim()) t = m.getAttribute("title") || "";
|
|
658
|
+
return t;
|
|
659
|
+
}
|
|
660
|
+
var EMAIL = /[\w.+-]+@[\w-]+(\.[\w-]+)+/g, DIGITS = /\d(?:[\s-]?\d){5,}/g, TOKEN = /[A-Za-z0-9_%=+-]{16,}/g;
|
|
661
|
+
var SECRET = /\b(?:(?:sk|pk|rk)_(?:live|test)_\w+|gh[pousr]_\w{20,}|github_pat_\w+|AKIA[0-9A-Z]{16}|xox[abprs]-[\w-]+|eyJ[\w-]+\.[\w-]+\.[\w-]*)/g, SAID = /\b((?:password|passwd|pwd|passcode|pin|secret|api[ _-]?key|token)\s*[:=]\s*)\S+/gi;
|
|
662
|
+
function tokens(t) { return t.replace(SECRET, "[token]").replace(TOKEN, function (w) { return /\d/.test(w) ? "[token]" : w; }); }
|
|
663
|
+
function scrub(t) { return tokens(String(t).replace(SAID, "$1[token]")).replace(EMAIL, "[email]").replace(DIGITS, "[number]"); }
|
|
664
|
+
function secretish(t) { return scrub(t) !== t; }
|
|
665
|
+
function cleanUrl(u) {
|
|
666
|
+
u = String(u).split(/[?#]/)[0].replace(/^([a-z][\w+.-]*:\/\/)[^@\/]*@/i, "$1");
|
|
667
|
+
if (/^(javascript|data|blob):/i.test(u)) return u.split(":")[0] + ":";
|
|
668
|
+
return scrub(u);
|
|
669
|
+
}
|
|
670
|
+
function label(m) {
|
|
671
|
+
var tag = m.tagName.toLowerCase();
|
|
672
|
+
var inner = m.querySelector("img[alt],[aria-label],title");
|
|
673
|
+
var alt = (m.getAttribute("alt") || (inner && (inner.getAttribute("alt") || inner.getAttribute("aria-label") || inner.textContent)) || "").trim();
|
|
674
|
+
var t = scrub(named(m)).trim().replace(/\s+/g, " ");
|
|
675
|
+
alt = scrub(alt);
|
|
676
|
+
if (!t && alt) t = (KIND[tag] ? KIND[tag] + ": " : "") + alt.replace(/\s+/g, " ");
|
|
677
|
+
if (!t) t = kind(m, tag);
|
|
678
|
+
return t.length > 28 ? t.slice(0, 27) + "..." : t;
|
|
679
|
+
}
|
|
680
|
+
function count(n, text, bad, good, parent) {
|
|
681
|
+
var p = document.createElement("p");
|
|
682
|
+
p.className = "n";
|
|
683
|
+
var b = document.createElement("b");
|
|
684
|
+
b.textContent = String(n);
|
|
685
|
+
if (bad) b.className = "e";
|
|
686
|
+
else if (good) b.className = "ok";
|
|
687
|
+
p.appendChild(b);
|
|
688
|
+
p.appendChild(document.createTextNode(text));
|
|
689
|
+
(parent || info).appendChild(p);
|
|
690
|
+
}
|
|
691
|
+
var CHIPS = 50;
|
|
692
|
+
function chipUl(parent, list, text, go) {
|
|
693
|
+
var ul = document.createElement("ul"), out = [];
|
|
694
|
+
ul.className = "m";
|
|
695
|
+
list.slice(0, CHIPS).forEach(function (m) {
|
|
696
|
+
var li = document.createElement("li");
|
|
697
|
+
var c = document.createElement("button");
|
|
698
|
+
c.className = "c";
|
|
699
|
+
c.type = "button";
|
|
700
|
+
c.textContent = text(m);
|
|
701
|
+
c.addEventListener("click", function () { go(m, c); });
|
|
702
|
+
out.push(c);
|
|
703
|
+
li.appendChild(c);
|
|
704
|
+
ul.appendChild(li);
|
|
705
|
+
});
|
|
706
|
+
if (list.length > CHIPS) {
|
|
707
|
+
var mo = document.createElement("li");
|
|
708
|
+
mo.className = "mo";
|
|
709
|
+
mo.textContent = "and " + (list.length - CHIPS).toLocaleString("en-US") + " more";
|
|
710
|
+
ul.appendChild(mo);
|
|
711
|
+
}
|
|
712
|
+
parent.appendChild(ul);
|
|
713
|
+
return out;
|
|
714
|
+
}
|
|
715
|
+
function fill() {
|
|
716
|
+
var had = chips.indexOf(root.activeElement);
|
|
717
|
+
while (info.firstChild) info.removeChild(info.firstChild);
|
|
718
|
+
chips = [];
|
|
719
|
+
drawn = sig();
|
|
720
|
+
count(stops.length, stops.length === 1 ? " stop for the Tab key" : " stops for the Tab key");
|
|
721
|
+
count(missed.length, missed.length === 0 ? " clickable things Tab skips" : missed.length === 1 ? " looks clickable, but Tab skips it" : " look clickable, but Tab skips them", missed.length > 0, missed.length === 0);
|
|
722
|
+
if (missed.indexOf(shownEl) < 0 && hovers.indexOf(shownEl) < 0 && forcedBad.indexOf(shownEl) < 0) shownEl = null;
|
|
723
|
+
if (missed.length) chipList(missed);
|
|
724
|
+
if (hovers.length) {
|
|
725
|
+
count(hovers.length, hovers.length === 1 ? " menu or box opens only on mouse hover" : " menus or boxes open only on mouse hover", true);
|
|
726
|
+
chipList(hovers);
|
|
727
|
+
}
|
|
728
|
+
if (forcedBad.length) {
|
|
729
|
+
count(forcedBad.length, forcedBad.length === 1 ? " stop has tabindex above 0, which pulls it ahead of the page" : " stops have tabindex above 0, which pulls them ahead of the page", true);
|
|
730
|
+
chipList(forcedBad, true);
|
|
731
|
+
}
|
|
732
|
+
if (skip) skipPanel();
|
|
733
|
+
if (had >= 0 && chips.length) chips[Math.min(had, chips.length - 1)].focus();
|
|
734
|
+
}
|
|
735
|
+
function sig() { return [stops.length].concat(missed, ["|"], hovers, ["|"], forced, ["|"], forcedBad); }
|
|
736
|
+
function chipList(list, num) {
|
|
737
|
+
var made = chipUl(info, list, function (m) { return (num && stops.indexOf(m) >= 0 ? stops.indexOf(m) + 1 + ": " : "") + label(m); }, function (m, c) {
|
|
738
|
+
shownEl = m;
|
|
739
|
+
chips.forEach(function (x) { x.setAttribute("aria-pressed", x === c ? "true" : "false"); });
|
|
740
|
+
m.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
741
|
+
queue();
|
|
742
|
+
});
|
|
743
|
+
made.forEach(function (c, i) { c.setAttribute("aria-pressed", list[i] === shownEl ? "true" : "false"); });
|
|
744
|
+
chips = chips.concat(made);
|
|
745
|
+
}
|
|
746
|
+
fill();
|
|
747
|
+
var PAGE = 50, win = 0, seen = -1;
|
|
748
|
+
var pager = document.createElement("p");
|
|
749
|
+
pager.className = "w";
|
|
750
|
+
var pageText = document.createElement("span");
|
|
751
|
+
pager.appendChild(pageText);
|
|
752
|
+
function pageBtn(text, step) {
|
|
753
|
+
var b = document.createElement("button");
|
|
754
|
+
b.className = "b";
|
|
755
|
+
b.type = "button";
|
|
756
|
+
b.setAttribute("aria-label", text);
|
|
757
|
+
icon(b, 14, step < 0 ? "M10 3L5 8l5 5" : "M6 3l5 5-5 5", 2);
|
|
758
|
+
b.addEventListener("mousedown", function (e) { e.preventDefault(); });
|
|
759
|
+
b.addEventListener("click", function () {
|
|
760
|
+
win = Math.min(Math.max(win + step, 0), Math.ceil(stops.length / PAGE) - 1);
|
|
761
|
+
queue();
|
|
762
|
+
});
|
|
763
|
+
pager.appendChild(b);
|
|
764
|
+
return b;
|
|
765
|
+
}
|
|
766
|
+
var prevBtn = pageBtn("Previous", -1), nextBtn = pageBtn("Next", 1);
|
|
767
|
+
var group = document.createElement("div");
|
|
768
|
+
group.className = "cd gp";
|
|
769
|
+
group.appendChild(pager);
|
|
770
|
+
var jumpBox = document.createElement("div");
|
|
771
|
+
resCard.appendChild(jumpBox);
|
|
772
|
+
panel.appendChild(group);
|
|
773
|
+
var jumps = [], pressed = 0, before = -1, popMissed = null, lost = false;
|
|
774
|
+
var POP = /cookie|consent|gdpr|modal|popup/i;
|
|
775
|
+
function dimmed() {
|
|
776
|
+
var W = innerWidth, H = innerHeight;
|
|
777
|
+
return Array.prototype.some.call(document.querySelectorAll("body *"), function (e) {
|
|
778
|
+
if (e.id === ID) return false;
|
|
779
|
+
var cs = getComputedStyle(e);
|
|
780
|
+
if (cs.position !== "fixed" || cs.display === "none" || cs.visibility === "hidden") return false;
|
|
781
|
+
var r = e.getBoundingClientRect();
|
|
782
|
+
if (r.width < W * 0.9 || r.height < H * 0.9) return false;
|
|
783
|
+
var m = cs.backgroundColor.match(/rgba?\(([^)]+)\)/);
|
|
784
|
+
var al = m ? m[1].split(",")[3] : null;
|
|
785
|
+
return (al !== undefined && al !== null && +al > 0 && +al < 1) || cs.backdropFilter !== "none" && cs.backdropFilter !== "";
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
function blocking(p) {
|
|
789
|
+
if (p.matches("dialog") && p.matches(":modal")) return true;
|
|
790
|
+
if (p.getAttribute("aria-modal") === "true") return true;
|
|
791
|
+
var r = p.getBoundingClientRect();
|
|
792
|
+
if (r.width * r.height >= innerWidth * innerHeight * 0.5) return true;
|
|
793
|
+
return dimmed();
|
|
794
|
+
}
|
|
795
|
+
function popupOf(el) {
|
|
796
|
+
for (var p = el; p && p !== document.documentElement; p = p.parentElement || (p.getRootNode().host || null)) {
|
|
797
|
+
if (p.nodeType !== 1) continue;
|
|
798
|
+
if (p.matches("dialog[open],[role=dialog],[role=alertdialog],[aria-modal=true]")) return p;
|
|
799
|
+
var c = typeof p.className === "string" ? p.className : "";
|
|
800
|
+
if (POP.test(p.id + " " + c) && getComputedStyle(p).position === "fixed") return p;
|
|
801
|
+
}
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
var covered = [], trapped = [], probHid = new Map();
|
|
805
|
+
function pinOf(e) {
|
|
806
|
+
for (var n = e; n && n.nodeType === 1; n = n.parentElement || (n.getRootNode() && n.getRootNode().host)) {
|
|
807
|
+
var pos = getComputedStyle(n).position;
|
|
808
|
+
if (pos === "fixed" || pos === "sticky") return n;
|
|
809
|
+
}
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
function hideInfo(s) {
|
|
813
|
+
var r = s.getBoundingClientRect();
|
|
814
|
+
if (r.width < 1 || r.height < 1) return { why: "has no size" };
|
|
815
|
+
var m = modal();
|
|
816
|
+
if (m && !within(m, s)) return { why: "is under an open modal" };
|
|
817
|
+
if (popupOf(s)) return { why: "is inside a popup" };
|
|
818
|
+
var pts = [[r.left + r.width / 2, r.top + r.height / 2], [r.left + 1, r.top + 1], [r.right - 1, r.top + 1], [r.left + 1, r.bottom - 1], [r.right - 1, r.bottom - 1]];
|
|
819
|
+
var tested = 0, under = 0, pin = null;
|
|
820
|
+
for (var i = 0; i < pts.length; i++) {
|
|
821
|
+
var px = pts[i][0], py = pts[i][1];
|
|
822
|
+
if (px < 0 || py < 0 || px >= innerWidth || py >= innerHeight) continue;
|
|
823
|
+
tested++;
|
|
824
|
+
var hit = null, list = document.elementsFromPoint(px, py);
|
|
825
|
+
for (var k = 0; k < list.length; k++) if (list[k] !== host && !host.contains(list[k])) { hit = list[k]; break; }
|
|
826
|
+
if (!hit || within(s, hit) || within(hit, s)) continue;
|
|
827
|
+
var p = pinOf(hit);
|
|
828
|
+
if (!p || within(p, s)) continue;
|
|
829
|
+
under++;
|
|
830
|
+
if (!pin) pin = p;
|
|
831
|
+
}
|
|
832
|
+
if (!tested) return { why: "is off screen" };
|
|
833
|
+
return { tested: tested, under: under, pin: pin };
|
|
834
|
+
}
|
|
835
|
+
function pinText(p) {
|
|
836
|
+
return desc(p) + " (" + getComputedStyle(p).position + ", " + Math.round(p.getBoundingClientRect().height) + " px tall)";
|
|
837
|
+
}
|
|
838
|
+
var moved = [], movedE = null;
|
|
839
|
+
function movedLine() {
|
|
840
|
+
if (movedE) {
|
|
841
|
+
var i = logs.indexOf(movedE);
|
|
842
|
+
if (i >= 0) logs.splice(i, 1);
|
|
843
|
+
if (movedE.li && movedE.li.parentNode) movedE.li.parentNode.removeChild(movedE.li);
|
|
844
|
+
movedE = null;
|
|
845
|
+
}
|
|
846
|
+
moved = moved.filter(function (x) { return x.isConnected; });
|
|
847
|
+
if (!moved.length) {
|
|
848
|
+
if (logList) logSummary();
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
var nums = moved.map(function (x) { return stops.indexOf(x) + 1; }).filter(function (n) { return n > 0; }).sort(function (a, b) { return a - b; });
|
|
852
|
+
var list = nums.length ? ": " + nums.slice(0, 20).join(", ") + (nums.length > 20 ? " and " + (nums.length - 20) + " more" : "") : "";
|
|
853
|
+
log("SKIPPED", "Hidden focus", [pl(moved.length, "stop", "stops") + " not tested, Tab moved on before the page stopped scrolling" + list + ". Press Play to test them."]);
|
|
854
|
+
movedE = logs[logs.length - 1];
|
|
855
|
+
}
|
|
856
|
+
function tested(s) {
|
|
857
|
+
var i = moved.indexOf(s);
|
|
858
|
+
if (i < 0) return;
|
|
859
|
+
moved.splice(i, 1);
|
|
860
|
+
movedLine();
|
|
861
|
+
}
|
|
862
|
+
function where(s) {
|
|
863
|
+
var r = s.getBoundingClientRect();
|
|
864
|
+
return scrollX + "," + scrollY + "," + r.left + "," + r.top;
|
|
865
|
+
}
|
|
866
|
+
function check(s, then) {
|
|
867
|
+
function end() {
|
|
868
|
+
var f = then;
|
|
869
|
+
then = null;
|
|
870
|
+
if (f) f();
|
|
871
|
+
}
|
|
872
|
+
if (!s) return end();
|
|
873
|
+
var was = covered.indexOf(s) >= 0;
|
|
874
|
+
var at = where(s), still = 0, tries = 0;
|
|
875
|
+
function look() {
|
|
876
|
+
if (closed || (covered.indexOf(s) >= 0) !== was) return end();
|
|
877
|
+
var now = where(s);
|
|
878
|
+
if (now !== at) {
|
|
879
|
+
if (stops[current] !== s) {
|
|
880
|
+
if (was) return end();
|
|
881
|
+
if (moved.indexOf(s) < 0) {
|
|
882
|
+
moved.push(s);
|
|
883
|
+
movedLine();
|
|
884
|
+
}
|
|
885
|
+
return end();
|
|
886
|
+
}
|
|
887
|
+
at = now;
|
|
888
|
+
still = 0;
|
|
889
|
+
} else still++;
|
|
890
|
+
if (still < 2 && ++tries < 90) return requestAnimationFrame(look);
|
|
891
|
+
var h = hideInfo(s);
|
|
892
|
+
tested(s);
|
|
893
|
+
hidTested.add(s);
|
|
894
|
+
if (!h.tested) {
|
|
895
|
+
log("SKIPPED", "Hidden focus", [ref(s), " " + h.why + ". Not tested."]);
|
|
896
|
+
return end();
|
|
897
|
+
}
|
|
898
|
+
if (was && h.under >= h.tested) {
|
|
899
|
+
log("INFO", "Hidden focus", [ref(s), " is already listed as hidden."]);
|
|
900
|
+
return end();
|
|
901
|
+
}
|
|
902
|
+
if (was) {
|
|
903
|
+
covered.splice(covered.indexOf(s), 1);
|
|
904
|
+
var pe = probHid.get(s);
|
|
905
|
+
if (pe) pe.fixed = true;
|
|
906
|
+
probHid.delete(s);
|
|
907
|
+
renderJumps();
|
|
908
|
+
end();
|
|
909
|
+
return log("OK", "Hidden focus", h.under ? [ref(s), " is not hidden anymore: it is partly covered by " + pinText(h.pin) + ", " + (h.tested - h.under) + " of " + h.tested + " points clear. That passes AA 2.4.11; AAA 2.4.12 needs it fully visible."] : [ref(s), " is not hidden anymore, " + h.tested + " of " + h.tested + " points clear."]);
|
|
910
|
+
}
|
|
911
|
+
if (h.under < h.tested) {
|
|
912
|
+
end();
|
|
913
|
+
return log("OK", "Hidden focus", h.under ? [ref(s), " is partly covered by " + pinText(h.pin) + ", " + (h.tested - h.under) + " of " + h.tested + " points clear. That passes AA 2.4.11; AAA 2.4.12 needs it fully visible."] : [ref(s), " is in view, " + h.tested + " of " + h.tested + " points clear."]);
|
|
914
|
+
}
|
|
915
|
+
covered.push(s);
|
|
916
|
+
renderJumps();
|
|
917
|
+
announce("Hidden focus: stop " + (stops.indexOf(s) + 1) + ", " + label(s) + ", is covered.");
|
|
918
|
+
var pr = h.pin.getBoundingClientRect(), up = pr.top + pr.height / 2 < innerHeight / 2, ph = Math.round(pr.height);
|
|
919
|
+
log("PROBLEM", "Hidden focus", [ref(s), ": all " + h.tested + " points are under " + pinText(h.pin) + "."], aiOf(W_HIDE, "When the element gets keyboard focus, at least part of it stays visible, not covered by " + desc(h.pin) + ".", "Add html { scroll-padding-" + (up ? "top" : "bottom") + ": " + (ph + 8) + "px; } so the browser scrolls focused elements clear of the " + (up ? "top" : "bottom") + " bar (" + ph + " px tall, plus 8 px of room).", [["Element", s], ["Covered by", h.pin]], ["Measured: " + desc(h.pin) + " is " + getComputedStyle(h.pin).position + ", " + ph + " px tall, at the " + (up ? "top" : "bottom") + " of a " + innerHeight + " px tall window."]));
|
|
920
|
+
probHid.set(s, logs[logs.length - 1]);
|
|
921
|
+
end();
|
|
922
|
+
}
|
|
923
|
+
requestAnimationFrame(look);
|
|
924
|
+
}
|
|
925
|
+
var popInfo = null, lostPops = [], openPop = null, opener = null, lastOut = null, tapIn = null, tapT = 0, lastKey = "", keyT = 0, keyOn = null;
|
|
926
|
+
function deep() {
|
|
927
|
+
var a = document.activeElement;
|
|
928
|
+
while (a && a.shadowRoot && a.shadowRoot.activeElement) a = a.shadowRoot.activeElement;
|
|
929
|
+
return a;
|
|
930
|
+
}
|
|
931
|
+
function gone(p) { return !p.isConnected || !shown(p) || (p.matches("dialog") && !p.open); }
|
|
932
|
+
function closedBy(p) {
|
|
933
|
+
var now = Date.now();
|
|
934
|
+
if (tapIn && now - tapT < 600 && within(p, tapIn)) {
|
|
935
|
+
var b = tapIn.closest ? tapIn.closest("button,a,[role=button]") : null;
|
|
936
|
+
return b ? " with \"" + label(b) + "\"" : " with a click";
|
|
937
|
+
}
|
|
938
|
+
if (keyT && now - keyT < 600) {
|
|
939
|
+
if (lastKey === "Escape") return " with Escape";
|
|
940
|
+
if (lastKey === "Enter" || lastKey === " ") return " with " + (lastKey === " " ? "Space" : "Enter") + (keyOn && keyOn.nodeType === 1 && keyOn !== document.body && keyOn !== document.documentElement ? " on \"" + label(keyOn) + "\"" : "");
|
|
941
|
+
}
|
|
942
|
+
return "";
|
|
943
|
+
}
|
|
944
|
+
function popClosed() {
|
|
945
|
+
var p = openPop, from = opener, pn = popName(p), by = closedBy(p), pi = popInfo;
|
|
946
|
+
openPop = null;
|
|
947
|
+
if (!from) return log("SKIPPED", "Lost focus", [pn, " closed" + by + ". It opened on its own, so there is no button to go back to."]);
|
|
948
|
+
if (!from.isConnected || !shown(from)) return log("SKIPPED", "Lost focus", [pn, " closed" + by + ". The button that opened it is gone or hidden."]);
|
|
949
|
+
if (lostPops.some(function (l) { return l[0] === from; })) return log("SKIPPED", "Lost focus", [pn, " closed" + by + ". Already listed."]);
|
|
950
|
+
if (tapIn && Date.now() - tapT < 600 && !within(p, tapIn)) return log("SKIPPED", "Lost focus", [pn, " closed by a click outside it. Not judged."]);
|
|
951
|
+
var frames = 0;
|
|
952
|
+
function look() {
|
|
953
|
+
if (closed) return;
|
|
954
|
+
var a = deep();
|
|
955
|
+
if (a && a !== document.body && a !== document.documentElement && !within(p, a) && shown(a)) {
|
|
956
|
+
if (a === from) return log("OK", "Lost focus", [pn, " closed" + by + ". Focus went back to ", ref(from), "."]);
|
|
957
|
+
return log("OK", "Lost focus", [pn, " closed" + by + ". Focus went to ", ref(a), ", not to the button that opened it, ", ref(from), "."]);
|
|
958
|
+
}
|
|
959
|
+
if (++frames < 30) return requestAnimationFrame(look);
|
|
960
|
+
if (lostPops.some(function (l) { return l[0] === from; })) return;
|
|
961
|
+
lostPops.push([from, p]);
|
|
962
|
+
renderJumps();
|
|
963
|
+
announce("Lost focus: " + pn.l + " closed and focus fell to the page body.");
|
|
964
|
+
log("PROBLEM", "Lost focus", [pn, " closed" + by + ". Focus fell to the page body instead of going back to ", ref(from), "."], aiOf(W_ORDER, "When the popup closes, focus goes back to the element that opened it, so a keyboard user carries on from there.", "Before the popup opens, store document.activeElement. After it closes, call .focus() on that element. A <dialog> opened with showModal() and closed with close() does this by itself, so if this one is a <dialog>, look for code that calls blur() or .focus() on something else after it closes.", [["Popup", p, pi], ["Opened by", from]]));
|
|
965
|
+
}
|
|
966
|
+
requestAnimationFrame(look);
|
|
967
|
+
}
|
|
968
|
+
function track(a) {
|
|
969
|
+
if (openPop && gone(openPop)) popClosed();
|
|
970
|
+
if (!a || a === document.body || a === document.documentElement || a === host || a.getRootNode() === root) return;
|
|
971
|
+
var p = popupOf(a);
|
|
972
|
+
if (!p) {
|
|
973
|
+
lastOut = a;
|
|
974
|
+
openPop = null;
|
|
975
|
+
} else if (!openPop) {
|
|
976
|
+
openPop = p;
|
|
977
|
+
opener = lastOut;
|
|
978
|
+
popInfo = { sel: sel(p), html: snip(p) };
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
function tap(e) {
|
|
982
|
+
tapIn = e.composedPath ? e.composedPath()[0] : e.target;
|
|
983
|
+
tapT = Date.now();
|
|
984
|
+
}
|
|
985
|
+
function stopGo(e) {
|
|
986
|
+
e.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
987
|
+
current = stops.indexOf(e);
|
|
988
|
+
queue();
|
|
989
|
+
}
|
|
990
|
+
function stopName(e) {
|
|
991
|
+
var i = stops.indexOf(e);
|
|
992
|
+
return (i >= 0 ? i + 1 : "?") + ": " + label(e);
|
|
993
|
+
}
|
|
994
|
+
function byStop(list) { return list.slice().sort(function (a, b) { return stops.indexOf(a) - stops.indexOf(b); }); }
|
|
995
|
+
function renderJumps() {
|
|
996
|
+
while (jumpBox.firstChild) jumpBox.removeChild(jumpBox.firstChild);
|
|
997
|
+
if (macNote) {
|
|
998
|
+
var mn = document.createElement("p");
|
|
999
|
+
mn.className = "mn";
|
|
1000
|
+
mn.textContent = MAC_NOTE;
|
|
1001
|
+
jumpBox.appendChild(mn);
|
|
1002
|
+
}
|
|
1003
|
+
if (popMissed) {
|
|
1004
|
+
count(1, " popup blocks the page, but Tab goes somewhere else first", true, false, jumpBox);
|
|
1005
|
+
chipUl(jumpBox, [popMissed], function () { return "Show the popup"; }, function (m) { m.scrollIntoView({ block: "center", behavior: "smooth" }); });
|
|
1006
|
+
}
|
|
1007
|
+
if (covered.length) {
|
|
1008
|
+
count(covered.length, covered.length === 1 ? " stop is hidden when Tab reaches it" : " stops are hidden when Tab reaches them", true, false, jumpBox);
|
|
1009
|
+
chipUl(jumpBox, byStop(covered), stopName, stopGo);
|
|
1010
|
+
}
|
|
1011
|
+
if (trapped.length) {
|
|
1012
|
+
count(trapped.length, trapped.length === 1 ? " stop where Tab gets stuck" : " stops where Tab gets stuck", true, false, jumpBox);
|
|
1013
|
+
chipUl(jumpBox, byStop(trapped), stopName, stopGo);
|
|
1014
|
+
}
|
|
1015
|
+
if (lostPops.length) {
|
|
1016
|
+
count(lostPops.length, lostPops.length === 1 ? " popup loses focus when it closes" : " popups lose focus when they close", true, false, jumpBox);
|
|
1017
|
+
chipUl(jumpBox, lostPops, function (l) {
|
|
1018
|
+
var i = stops.indexOf(l[0]);
|
|
1019
|
+
return (i >= 0 ? i + 1 : label(l[0])) + " \u2192 Start";
|
|
1020
|
+
}, function (l) { stopGo(l[0]); });
|
|
1021
|
+
}
|
|
1022
|
+
if (jumps.length) {
|
|
1023
|
+
count(jumps.length, jumps.length === 1 ? " time Tab jumped out of order" : " times Tab jumped out of order", true, false, jumpBox);
|
|
1024
|
+
chipUl(jumpBox, jumps, function (j) {
|
|
1025
|
+
var from = j[0] ? stops.indexOf(j[0]) + 1 || label(j[0]) : "Start", to = stops.indexOf(j[1]) + 1;
|
|
1026
|
+
return from + " \u2192 " + (to || "?");
|
|
1027
|
+
}, function (j) { stopGo(j[1]); });
|
|
1028
|
+
}
|
|
1029
|
+
if (skip) skipPanel();
|
|
1030
|
+
}
|
|
1031
|
+
var legend = document.createElement("div");
|
|
1032
|
+
legend.className = "so";
|
|
1033
|
+
legend.hidden = true;
|
|
1034
|
+
legend.appendChild(line("k", null, "The order Tab visits", "d"));
|
|
1035
|
+
legend.appendChild(line("k", null, "Hidden until Tab reaches it", "h"));
|
|
1036
|
+
legend.appendChild(line("k", null, "Tab can't reach or see it", "r"));
|
|
1037
|
+
var tray = document.createElement("div");
|
|
1038
|
+
tray.className = "tr";
|
|
1039
|
+
panel.appendChild(tray);
|
|
1040
|
+
var gear = document.createElement("button");
|
|
1041
|
+
gear.className = "sg";
|
|
1042
|
+
gear.type = "button";
|
|
1043
|
+
gear.setAttribute("aria-expanded", "false");
|
|
1044
|
+
var gearIcon = icon(gear, 16, "M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.4 3.4l1.4 1.4M11.2 11.2l1.4 1.4M3.4 12.6l1.4-1.4M11.2 4.8l1.4-1.4", 1.6);
|
|
1045
|
+
el("circle", { cx: 8, cy: 8, r: 2.2 }, gearIcon);
|
|
1046
|
+
gear.appendChild(document.createTextNode("Settings"));
|
|
1047
|
+
gear.appendChild(document.createElement("i"));
|
|
1048
|
+
tray.appendChild(gear);
|
|
1049
|
+
var settings = document.createElement("div");
|
|
1050
|
+
settings.className = "so";
|
|
1051
|
+
settings.hidden = true;
|
|
1052
|
+
tray.appendChild(settings);
|
|
1053
|
+
gear.addEventListener("click", function () {
|
|
1054
|
+
settings.hidden = !settings.hidden;
|
|
1055
|
+
gear.setAttribute("aria-expanded", settings.hidden ? "false" : "true");
|
|
1056
|
+
});
|
|
1057
|
+
var skipBox = document.createElement("label");
|
|
1058
|
+
skipBox.className = "k s";
|
|
1059
|
+
var skip = document.createElement("input");
|
|
1060
|
+
skip.type = "checkbox";
|
|
1061
|
+
skip.checked = true;
|
|
1062
|
+
skipBox.appendChild(skip);
|
|
1063
|
+
skipBox.appendChild(document.createTextNode("Leave this panel out of Tab"));
|
|
1064
|
+
settings.appendChild(skipBox);
|
|
1065
|
+
var tightBox = document.createElement("label");
|
|
1066
|
+
tightBox.className = "k s";
|
|
1067
|
+
var tight = document.createElement("input");
|
|
1068
|
+
tight.type = "checkbox";
|
|
1069
|
+
tight.checked = true;
|
|
1070
|
+
tightBox.appendChild(tight);
|
|
1071
|
+
tightBox.appendChild(document.createTextNode("Compact view"));
|
|
1072
|
+
settings.appendChild(tightBox);
|
|
1073
|
+
tight.addEventListener("change", function () { panel.classList.toggle("rm", !tight.checked); });
|
|
1074
|
+
var chunkBox = document.createElement("label");
|
|
1075
|
+
chunkBox.className = "k s";
|
|
1076
|
+
var chunk = document.createElement("input");
|
|
1077
|
+
chunk.type = "checkbox";
|
|
1078
|
+
chunk.checked = true;
|
|
1079
|
+
chunkBox.appendChild(chunk);
|
|
1080
|
+
chunkBox.appendChild(document.createTextNode("Show " + PAGE + " stops at a time"));
|
|
1081
|
+
group.appendChild(chunkBox);
|
|
1082
|
+
var shortBox = document.createElement("label");
|
|
1083
|
+
shortBox.className = "k s";
|
|
1084
|
+
var stub = document.createElement("input");
|
|
1085
|
+
stub.type = "checkbox";
|
|
1086
|
+
stub.checked = true;
|
|
1087
|
+
shortBox.appendChild(stub);
|
|
1088
|
+
shortBox.appendChild(document.createTextNode("Long lines"));
|
|
1089
|
+
settings.insertBefore(shortBox, skipBox);
|
|
1090
|
+
var lineBox = document.createElement("label");
|
|
1091
|
+
lineBox.className = "k s";
|
|
1092
|
+
var lines = document.createElement("input");
|
|
1093
|
+
lines.type = "checkbox";
|
|
1094
|
+
lines.checked = true;
|
|
1095
|
+
lineBox.appendChild(lines);
|
|
1096
|
+
lineBox.appendChild(document.createTextNode("Show lines"));
|
|
1097
|
+
settings.insertBefore(lineBox, shortBox);
|
|
1098
|
+
lines.addEventListener("change", function () {
|
|
1099
|
+
stub.disabled = !lines.checked;
|
|
1100
|
+
shortBox.classList.toggle("off", !lines.checked);
|
|
1101
|
+
queue();
|
|
1102
|
+
});
|
|
1103
|
+
stub.addEventListener("change", function () { queue(); });
|
|
1104
|
+
var spotBox = document.createElement("label");
|
|
1105
|
+
spotBox.className = "k s";
|
|
1106
|
+
var light = document.createElement("input");
|
|
1107
|
+
light.type = "checkbox";
|
|
1108
|
+
spotBox.appendChild(light);
|
|
1109
|
+
spotBox.appendChild(document.createTextNode("Spotlight"));
|
|
1110
|
+
settings.insertBefore(spotBox, settings.firstChild);
|
|
1111
|
+
light.addEventListener("change", function () { queue(); });
|
|
1112
|
+
chunk.addEventListener("change", function () { queue(); });
|
|
1113
|
+
function paged() { return chunk.checked && stops.length > PAGE; }
|
|
1114
|
+
function outT() { return skip.checked && !panelIn ? -1 : 0; }
|
|
1115
|
+
function skipPanel() {
|
|
1116
|
+
panel.tabIndex = outT();
|
|
1117
|
+
panel.querySelectorAll("button,a,input").forEach(function (e) { e.tabIndex = e.className === "lc" ? (panelIn ? 0 : -1) : outT(); });
|
|
1118
|
+
}
|
|
1119
|
+
skip.addEventListener("change", function () {
|
|
1120
|
+
skipPanel();
|
|
1121
|
+
svg.classList.toggle("in", !skip.checked);
|
|
1122
|
+
svgPg.classList.toggle("in", !skip.checked);
|
|
1123
|
+
dot.classList.toggle("in", !skip.checked);
|
|
1124
|
+
dotPg.classList.toggle("in", !skip.checked);
|
|
1125
|
+
rescan();
|
|
1126
|
+
});
|
|
1127
|
+
var a = document.createElement("a");
|
|
1128
|
+
a.className = "a";
|
|
1129
|
+
a.href = "https://matjazkorosec.com/tools/tab-trail";
|
|
1130
|
+
a.target = "_blank";
|
|
1131
|
+
a.rel = "noopener";
|
|
1132
|
+
a.textContent = "matjazkorosec.com/tools/tab-trail";
|
|
1133
|
+
var how = document.createElement("p");
|
|
1134
|
+
how.className = "hw";
|
|
1135
|
+
var MAC = /Mac/.test(navigator.platform || navigator.userAgent);
|
|
1136
|
+
var KEYS = "Ctrl+Shift+F";
|
|
1137
|
+
var ver = document.createElement("span");
|
|
1138
|
+
ver.className = "vr";
|
|
1139
|
+
ver.textContent = "v" + VERSION;
|
|
1140
|
+
how.appendChild(ver);
|
|
1141
|
+
how.appendChild(document.createTextNode("How to use & latest version: "));
|
|
1142
|
+
how.appendChild(a);
|
|
1143
|
+
var keysBtn = document.createElement("button");
|
|
1144
|
+
keysBtn.className = "sg";
|
|
1145
|
+
keysBtn.type = "button";
|
|
1146
|
+
keysBtn.setAttribute("aria-expanded", "false");
|
|
1147
|
+
icon(keysBtn, 16, "M1.5 4.5h13v7h-13zM4 7h1M7.5 7h1M11 7h1M5 9.5h6", 1.6);
|
|
1148
|
+
keysBtn.appendChild(document.createTextNode("Shortcuts"));
|
|
1149
|
+
keysBtn.appendChild(document.createElement("i"));
|
|
1150
|
+
tray.insertBefore(keysBtn, gear);
|
|
1151
|
+
var keysBox = document.createElement("div");
|
|
1152
|
+
keysBox.className = "so";
|
|
1153
|
+
keysBox.hidden = true;
|
|
1154
|
+
tray.insertBefore(keysBox, gear);
|
|
1155
|
+
[[KEYS + ":", " into this panel"], ["Escape:", " back to the page"], ["Tab, Shift+Tab:", " along the trail"], ["Space or Escape:", " pause Play"]].forEach(function (k) {
|
|
1156
|
+
keysBox.appendChild(line("k", k[0], k[1]));
|
|
1157
|
+
});
|
|
1158
|
+
keysBtn.addEventListener("click", function () {
|
|
1159
|
+
keysBox.hidden = !keysBox.hidden;
|
|
1160
|
+
keysBtn.setAttribute("aria-expanded", keysBox.hidden ? "false" : "true");
|
|
1161
|
+
});
|
|
1162
|
+
var legendBtn = document.createElement("button");
|
|
1163
|
+
legendBtn.className = "sg";
|
|
1164
|
+
legendBtn.type = "button";
|
|
1165
|
+
legendBtn.setAttribute("aria-expanded", "false");
|
|
1166
|
+
icon(legendBtn, 16, "M3 4h1M6.5 4H13M3 8h1M6.5 8H13M3 12h1M6.5 12H13", 1.6);
|
|
1167
|
+
legendBtn.appendChild(document.createTextNode("Legend"));
|
|
1168
|
+
legendBtn.appendChild(document.createElement("i"));
|
|
1169
|
+
tray.insertBefore(legendBtn, keysBtn);
|
|
1170
|
+
tray.insertBefore(legend, keysBtn);
|
|
1171
|
+
legendBtn.addEventListener("click", function () {
|
|
1172
|
+
legend.hidden = !legend.hidden;
|
|
1173
|
+
legendBtn.setAttribute("aria-expanded", legend.hidden ? "false" : "true");
|
|
1174
|
+
});
|
|
1175
|
+
tray.appendChild(how);
|
|
1176
|
+
var logs = [], logFilter = "all", logOpen = false, LOG_MAX = 500, showWcag = false, wcagBoxes = [];
|
|
1177
|
+
function wcagBox(parent, doc) {
|
|
1178
|
+
var lb = doc.createElement("label");
|
|
1179
|
+
lb.className = "lw";
|
|
1180
|
+
var cb = doc.createElement("input");
|
|
1181
|
+
cb.type = "checkbox";
|
|
1182
|
+
cb.checked = showWcag;
|
|
1183
|
+
cb.addEventListener("change", function () {
|
|
1184
|
+
showWcag = cb.checked;
|
|
1185
|
+
wcagSync();
|
|
1186
|
+
});
|
|
1187
|
+
lb.appendChild(cb);
|
|
1188
|
+
lb.appendChild(doc.createTextNode("Show WCAG"));
|
|
1189
|
+
parent.appendChild(lb);
|
|
1190
|
+
wcagBoxes.push(cb);
|
|
1191
|
+
return cb;
|
|
1192
|
+
}
|
|
1193
|
+
function wcagSync() {
|
|
1194
|
+
wcagBoxes.forEach(function (b) { b.checked = showWcag; });
|
|
1195
|
+
logGroup.classList.toggle("nw", !showWcag);
|
|
1196
|
+
if (tabOpen()) logTab.document.body.classList.toggle("nw", !showWcag);
|
|
1197
|
+
}
|
|
1198
|
+
var lastStops = -1, lastMissed = -1, lastForced = -1, probMiss = new Map(), probHov = new Map(), probForce = new Map(), seenForce = new WeakSet(), seenOk = new WeakSet(), seenCss = new Set();
|
|
1199
|
+
var RES = { OK: "ok", PROBLEM: "bad", SKIPPED: "skip", INFO: "info" };
|
|
1200
|
+
var FILT = [["all", "All"], ["bad", "Problems"], ["ok", "OK"], ["skip", "Skipped"]];
|
|
1201
|
+
var tabChecked = null, filterSets = [], logTab = null, tabList = null, tabSum = null, tabSet = null, tabNote = null, tabPoll = 0;
|
|
1202
|
+
function pl(n, one, many) { return n + " " + (n === 1 ? one : many); }
|
|
1203
|
+
function desc(e) {
|
|
1204
|
+
var t = e.tagName.toLowerCase();
|
|
1205
|
+
if (e.id) return t + "#" + scrub(e.id);
|
|
1206
|
+
var c = typeof e.className === "string" ? e.className.trim().split(/\s+/).filter(Boolean).slice(0, 2) : [];
|
|
1207
|
+
return c.length ? t + "." + scrub(c.join(".")) : t;
|
|
1208
|
+
}
|
|
1209
|
+
function ref(e) { return { el: e, n: stops.indexOf(e) + 1, l: label(e), d: desc(e) }; }
|
|
1210
|
+
function popName(p) {
|
|
1211
|
+
var n = p.getAttribute("aria-label") || "", by = p.getAttribute("aria-labelledby");
|
|
1212
|
+
if (!n && by) {
|
|
1213
|
+
var t = document.getElementById(by.split(/\s+/)[0]);
|
|
1214
|
+
if (t) n = t.textContent || "";
|
|
1215
|
+
}
|
|
1216
|
+
if (!n) {
|
|
1217
|
+
var h = p.querySelector("h1,h2,h3,h4,legend");
|
|
1218
|
+
if (h) n = h.textContent || "";
|
|
1219
|
+
}
|
|
1220
|
+
n = scrub(n).trim().replace(/\s+/g, " ");
|
|
1221
|
+
if (n.length > 28) n = n.slice(0, 27) + "...";
|
|
1222
|
+
return { el: p, n: 0, l: n || label(p), d: desc(p) };
|
|
1223
|
+
}
|
|
1224
|
+
function partText(x) { return typeof x === "string" ? x : x.n ? x.n + " \"" + x.l + "\"" : "\"" + x.l + "\" " + x.d; }
|
|
1225
|
+
function looksWhy(m) {
|
|
1226
|
+
var why = [], role = m.getAttribute("role") || "";
|
|
1227
|
+
if (m.tagName === "A" && !m.hasAttribute("href")) why.push("a link with no address");
|
|
1228
|
+
if (m.hasAttribute("onclick")) why.push("a click handler in the HTML");
|
|
1229
|
+
if (ROLES.test(role)) why.push("role=\"" + role + "\"");
|
|
1230
|
+
if (getComputedStyle(m).cursor === "pointer") why.push("a pointer cursor");
|
|
1231
|
+
return why.length ? "has " + why.join(", ") : "looks clickable";
|
|
1232
|
+
}
|
|
1233
|
+
function addr() { return location.protocol + "//" + location.host + cleanUrl(location.pathname); }
|
|
1234
|
+
function two(n) { return (n < 10 ? "0" : "") + n; }
|
|
1235
|
+
function clock(t) { return two(t.getHours()) + ":" + two(t.getMinutes()) + ":" + two(t.getSeconds()); }
|
|
1236
|
+
function browser() {
|
|
1237
|
+
var u = navigator.userAgent, m;
|
|
1238
|
+
if ((m = u.match(/Edg\/(\d+)/))) return "Edge " + m[1];
|
|
1239
|
+
if ((m = u.match(/Firefox\/(\d+)/))) return "Firefox " + m[1];
|
|
1240
|
+
if ((m = u.match(/Chrome\/(\d+)/))) return "Chrome " + m[1];
|
|
1241
|
+
if ((m = u.match(/Version\/(\d+)[^ ]* (Mobile\/\S+ )?Safari/))) return "Safari " + m[1];
|
|
1242
|
+
return u;
|
|
1243
|
+
}
|
|
1244
|
+
var CHECKS = ["Missed spots", "Hover menus", "Forced order", "Out of order", "Keyboard trap", "Hidden focus", "Lost focus"];
|
|
1245
|
+
var WCAG = { "Missed spots": "2.1.1 A", "Hover menus": "2.1.1 A", "Out of order": "2.4.3 A", "Forced order": "2.4.3 A", "Keyboard trap": "2.1.2 A", "Lost focus": "2.4.3 A", "Hidden focus": "2.4.11 AA" };
|
|
1246
|
+
function showUrl(f) { return "https://matjazkorosec.com/tools/tab-trail#show-" + f.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""); }
|
|
1247
|
+
function ranChecks() {
|
|
1248
|
+
var out = [];
|
|
1249
|
+
logs.forEach(function (e) { if (e.k !== "INFO" && CHECKS.indexOf(e.f) >= 0 && out.indexOf(e.f) < 0) out.push(e.f); });
|
|
1250
|
+
return out;
|
|
1251
|
+
}
|
|
1252
|
+
var checkedKey = {};
|
|
1253
|
+
function checkedLine(p, doc) {
|
|
1254
|
+
var ran = ranChecks(), bad = {};
|
|
1255
|
+
logs.forEach(function (e) { if (e.k === "PROBLEM" && !e.fixed) bad[e.f] = 1; });
|
|
1256
|
+
var k = ran.map(function (f) { return f + (bad[f] ? "!" : ""); }).join("|");
|
|
1257
|
+
p.hidden = !ran.length;
|
|
1258
|
+
if (checkedKey[p.className + (doc === document ? "1" : "2")] === k && p.firstChild) return;
|
|
1259
|
+
checkedKey[p.className + (doc === document ? "1" : "2")] = k;
|
|
1260
|
+
while (p.firstChild) p.removeChild(p.firstChild);
|
|
1261
|
+
p.appendChild(doc.createTextNode("Checked: "));
|
|
1262
|
+
ran.forEach(function (f, i) {
|
|
1263
|
+
if (i) p.appendChild(doc.createTextNode(", "));
|
|
1264
|
+
var a = doc.createElement("a");
|
|
1265
|
+
a.className = bad[f] ? "lq bad" : "lq";
|
|
1266
|
+
a.href = showUrl(f);
|
|
1267
|
+
a.target = "_blank";
|
|
1268
|
+
a.rel = "noopener";
|
|
1269
|
+
a.textContent = f;
|
|
1270
|
+
a.title = "What " + f + " checks";
|
|
1271
|
+
if (doc === document) a.tabIndex = outT();
|
|
1272
|
+
p.appendChild(a);
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
function res(e) { return e.fixed ? "fixed" : RES[e.k]; }
|
|
1276
|
+
function shows(e) { return logFilter === "all" || res(e) === logFilter; }
|
|
1277
|
+
function logCounts() {
|
|
1278
|
+
var c = { all: logs.length, bad: 0, ok: 0, skip: 0, info: 0, fixed: 0 };
|
|
1279
|
+
logs.forEach(function (e) { c[res(e)]++; });
|
|
1280
|
+
return c;
|
|
1281
|
+
}
|
|
1282
|
+
function tabOpen() { return !!(logTab && !logTab.closed); }
|
|
1283
|
+
function logView() { return tabOpen() ? tabList : logOpen ? logList : null; }
|
|
1284
|
+
function scroller(v) { return v === logList ? panel : v.ownerDocument.scrollingElement || v.ownerDocument.documentElement; }
|
|
1285
|
+
function toTop(v) {
|
|
1286
|
+
if (v !== logList) return void (scroller(v).scrollTop = 0);
|
|
1287
|
+
var d = v.getBoundingClientRect().top - panel.getBoundingClientRect().top;
|
|
1288
|
+
if (d < 0) panel.scrollTop += d - 12;
|
|
1289
|
+
}
|
|
1290
|
+
function wcagOf(e) { return e.w || WCAG[e.f]; }
|
|
1291
|
+
function log(k, f, parts, ai, w) {
|
|
1292
|
+
var e = { t: new Date(), k: k, f: f, p: parts, li: null, ai: ai || null, w: w || null };
|
|
1293
|
+
logs.push(e);
|
|
1294
|
+
if (k === "PROBLEM" && e.ai) probLog.push(e);
|
|
1295
|
+
if ((k === "OK" || k === "PROBLEM") && (f === "Out of order" || f === "Keyboard trap") && pressed) judgedDir[pressed > 0 ? 1 : -1] = 1;
|
|
1296
|
+
if (logs.length > LOG_MAX) {
|
|
1297
|
+
var old = logs.shift();
|
|
1298
|
+
if (old.li && old.li.parentNode) old.li.parentNode.removeChild(old.li);
|
|
1299
|
+
}
|
|
1300
|
+
if (!logList) return;
|
|
1301
|
+
logSummary();
|
|
1302
|
+
var v = logView();
|
|
1303
|
+
if (!v || !shows(e)) return;
|
|
1304
|
+
var sc = scroller(v), top = v === logList ? v.getBoundingClientRect().top >= sc.getBoundingClientRect().top : sc.scrollTop < 8;
|
|
1305
|
+
e.li = logLi(e, v.ownerDocument);
|
|
1306
|
+
v.insertBefore(e.li, v.firstChild);
|
|
1307
|
+
if (top) { if (v !== logList) sc.scrollTop = 0; }
|
|
1308
|
+
else sc.scrollTop += e.li.getBoundingClientRect().height;
|
|
1309
|
+
}
|
|
1310
|
+
function review() {
|
|
1311
|
+
if (lastStops < 0) log("INFO", "Scan", ["Found " + pl(stops.length, "stop", "stops") + ". Read " + pl(cssRules, "CSS rule", "CSS rules") + " from " + pl(cssSheets, "style sheet", "style sheets") + "."]);
|
|
1312
|
+
else if (stops.length !== lastStops) log("INFO", "Scan", ["Page changed: " + pl(stops.length, "stop", "stops") + " now, " + lastStops + " before."]);
|
|
1313
|
+
lastStops = stops.length;
|
|
1314
|
+
cssBlocked.forEach(function (h) {
|
|
1315
|
+
if (seenCss.has(h)) return;
|
|
1316
|
+
seenCss.add(h);
|
|
1317
|
+
log("SKIPPED", "Hover menus", ["Can't read " + cleanUrl(h) + ", it comes from another site."]);
|
|
1318
|
+
});
|
|
1319
|
+
var mSet = new Set(missed), hSet = new Set(hovers), fSet = new Set(forcedBad), fresh = {}, nNew = 0;
|
|
1320
|
+
function add(f) {
|
|
1321
|
+
fresh[f] = 1;
|
|
1322
|
+
nNew++;
|
|
1323
|
+
}
|
|
1324
|
+
probMiss.forEach(function (e, m) {
|
|
1325
|
+
if (mSet.has(m)) return;
|
|
1326
|
+
e.fixed = true;
|
|
1327
|
+
probMiss.delete(m);
|
|
1328
|
+
log("OK", "Missed spots", [ref(m), stopSet.has(m) ? " is a Tab stop now." : m.isConnected ? " is no longer flagged." : " is gone from the page."]);
|
|
1329
|
+
});
|
|
1330
|
+
probHov.forEach(function (e, h) {
|
|
1331
|
+
if (hSet.has(h)) return;
|
|
1332
|
+
e.fixed = true;
|
|
1333
|
+
probHov.delete(h);
|
|
1334
|
+
if (tabOpens.has(h)) seenOk.add(h);
|
|
1335
|
+
log("OK", "Hover menus", [ref(h), !h.isConnected ? " is gone from the page." : tabOpens.has(h) ? " opens when Tab reaches it." : " no longer opens only on mouse hover."]);
|
|
1336
|
+
});
|
|
1337
|
+
missed.forEach(function (m) {
|
|
1338
|
+
if (probMiss.has(m)) return;
|
|
1339
|
+
var item = m.closest(GROUP) && ITEM.test(m.getAttribute("role") || "");
|
|
1340
|
+
log("PROBLEM", "Missed spots", [ref(m), " " + looksWhy(m) + ", but Tab never reaches it."], aiOf(W_KEY, "Every element that reacts to a click can be reached with the Tab key and used with Enter or Space.", item ? "It is a role=\"" + m.getAttribute("role") + "\" item in a group the arrow keys move through, and no item in the group is a Tab stop. Give 1 item tabindex=\"0\" (the selected one) and move between the items with the arrow keys." : m.tagName === "A" && !m.hasAttribute("href") ? "Give the link an href, or make it a <button type=\"button\"> if it runs script." : "Use <button type=\"button\"> for an action or <a href> for a link instead of the " + m.tagName.toLowerCase() + ". If the tag can't change, add tabindex=\"0\" and role=\"button\", and handle Enter and Space in a keydown listener." + (looksWhy(m) === "has a pointer cursor" ? " Only the pointer cursor makes it look clickable: if it is not meant to be clickable, remove cursor: pointer from it instead." : ""), [["Element", m]], null, true));
|
|
1341
|
+
probMiss.set(m, logs[logs.length - 1]);
|
|
1342
|
+
add("Missed spots");
|
|
1343
|
+
});
|
|
1344
|
+
if (!missed.length && lastMissed !== 0) log("OK", "Missed spots", [lastMissed > 0 ? "No clickable things Tab skips now." : "No clickable things Tab skips."]);
|
|
1345
|
+
lastMissed = missed.length;
|
|
1346
|
+
hoverOk.forEach(function (o) {
|
|
1347
|
+
if (seenOk.has(o[0])) return;
|
|
1348
|
+
seenOk.add(o[0]);
|
|
1349
|
+
log("OK", "Hover menus", [ref(o[0]), o[1] === "focus" ? " opens on mouse hover and on keyboard focus." : o[1] === "tab" ? " opens when Tab reaches it." : " opens on mouse hover and has a toggle button (aria-expanded), so the keyboard can open it."]);
|
|
1350
|
+
});
|
|
1351
|
+
hovers.forEach(function (h) {
|
|
1352
|
+
if (probHov.has(h)) return;
|
|
1353
|
+
var hr = hovRule.get(h) || [":hover", ""];
|
|
1354
|
+
hr = [scrub(hr[0]), hr[1]];
|
|
1355
|
+
var tw = (hr[0].match(/\.(?:[\w-]|\\.)+/g) || []).map(function (c) { return c.slice(1).replace(/\\(.)/g, "$1"); }).filter(function (c) { return /(^|:)(group-|peer-)?hover:/.test(c); })[0];
|
|
1356
|
+
var twFix = tw ? "This rule comes from the Tailwind class " + tw + ". Add " + tw.replace(/(^|:)group-hover:/, "$1group-focus-within:").replace(/(^|:)peer-hover:/, "$1peer-focus:").replace(/(^|:)hover:/, "$1focus-within:") + " next to it in the same class list, so it also opens on keyboard focus. Or open the menu with a <button aria-expanded> that toggles it." : "";
|
|
1357
|
+
var seen = hovSeen.has(h);
|
|
1358
|
+
var dead = !seen && !h.matches(FOCUSABLE) && ![].some.call(h.querySelectorAll(FOCUSABLE), function (x) { return tabbable(x); });
|
|
1359
|
+
var skipped = [].some.call(h.querySelectorAll(FOCUSABLE), function (x) { return x.tabIndex < 0; });
|
|
1360
|
+
var deadFix = dead ? " Nothing inside it can take keyboard focus now, so a focus rule alone will never open it: make the part you hover a <button type=\"button\" aria-expanded=\"false\"> that toggles the menu." + (skipped ? " The links or buttons inside have tabindex=\"-1\", so Tab skips them even when the menu is open: remove it." : "") : "";
|
|
1361
|
+
log("PROBLEM", "Hover menus", [ref(h), " opens only on mouse hover (" + hr[0] + ")." + (seen ? " Tab reaches its links, but they stay invisible while they have focus." : " No focus rule, no toggle button.")], aiOf(seen ? W_VIS : W_KEY, seen ? "The menu also opens while a link or button inside it has keyboard focus, so keyboard users can see where they are." : "The menu also opens when a link or button inside it gets keyboard focus, so keyboard users can reach its links.", (twFix || "Next to the rule " + hr[0] + " add " + hr[0].replace(/:hover/g, ":focus-within") + " with the same declarations, or open the menu with a <button aria-expanded> that toggles it.") + deadFix, [["Element", h, null, true]], ["CSS rule: " + hr[0], "Style sheet: " + (hr[1] ? cleanUrl(hr[1]) : "unknown")], true), seen ? "2.4.7 AA" : null);
|
|
1362
|
+
probHov.set(h, logs[logs.length - 1]);
|
|
1363
|
+
add("Hover menus");
|
|
1364
|
+
});
|
|
1365
|
+
probForce.forEach(function (e, f) {
|
|
1366
|
+
if (fSet.has(f)) return;
|
|
1367
|
+
e.fixed = true;
|
|
1368
|
+
probForce.delete(f);
|
|
1369
|
+
log("OK", "Forced order", [ref(f), !f.isConnected ? " is gone from the page." : forced.indexOf(f) >= 0 ? " is in page order now." : f.tabIndex > 0 ? " is no longer a Tab stop." : " has no tabindex above 0 now."]);
|
|
1370
|
+
});
|
|
1371
|
+
forced.forEach(function (f) {
|
|
1372
|
+
if (probForce.has(f) || (!fSet.has(f) && seenForce.has(f))) return;
|
|
1373
|
+
var ti = f.getAttribute("tabindex"), at = stops.indexOf(f) + 1, page = domAt.get(f) + 1;
|
|
1374
|
+
if (!fSet.has(f)) {
|
|
1375
|
+
seenForce.add(f);
|
|
1376
|
+
return log("INFO", "Forced order", [ref(f), " has tabindex=\"" + ti + "\", but it is already in page order, so Tab order stays the same. tabindex above 0 pulls it ahead of the page. It fails WCAG 2.4.3 when that order makes no sense (F44)."]);
|
|
1377
|
+
}
|
|
1378
|
+
seenForce.delete(f);
|
|
1379
|
+
log("PROBLEM", "Forced order", [ref(f), " has tabindex=\"" + ti + "\", which pulls it ahead of the page: Tab visits it as stop " + at + ", its place in the page is stop " + page + ". It fails WCAG 2.4.3 when that order makes no sense (F44)."], aiOf(W_FORCE, "Tab follows the order of the page. No element has tabindex above 0, so none is pulled ahead of the rest.", "Remove the tabindex, or set it to 0, and move the element in the HTML where it should come in Tab order.", [["Element", f]], ["Measured: tabindex=\"" + ti + "\", Tab visits it as stop " + at + ", its place in the page is stop " + page + ". " + pl(forced.length, "stop", "stops") + " on the page " + (forced.length === 1 ? "has" : "have") + " tabindex above 0."], true));
|
|
1380
|
+
probForce.set(f, logs[logs.length - 1]);
|
|
1381
|
+
add("Forced order");
|
|
1382
|
+
});
|
|
1383
|
+
if (!forcedBad.length && lastForced !== 0) log("OK", "Forced order", [forced.length ? "No stop with tabindex above 0 is out of page order" + (lastForced > 0 ? " now." : ".") : lastForced > 0 ? "No stops with tabindex above 0 now." : "No stops with tabindex above 0."]);
|
|
1384
|
+
lastForced = forcedBad.length;
|
|
1385
|
+
if (nNew) announce(pl(nNew, "new problem", "new problems") + ": " + Object.keys(fresh).join(", ") + ".");
|
|
1386
|
+
}
|
|
1387
|
+
function goTo(e) {
|
|
1388
|
+
if (!e.isConnected) return;
|
|
1389
|
+
e.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
1390
|
+
if (stops.indexOf(e) < 0) return queue();
|
|
1391
|
+
endPress();
|
|
1392
|
+
e.focus({ preventScroll: true, focusVisible: true });
|
|
1393
|
+
focus();
|
|
1394
|
+
}
|
|
1395
|
+
function logLi(e, doc) {
|
|
1396
|
+
var li = doc.createElement("li");
|
|
1397
|
+
li.className = "lx " + RES[e.k];
|
|
1398
|
+
function sp(cls, text) {
|
|
1399
|
+
var x = doc.createElement("span");
|
|
1400
|
+
x.className = cls;
|
|
1401
|
+
x.textContent = text;
|
|
1402
|
+
li.appendChild(x);
|
|
1403
|
+
return x;
|
|
1404
|
+
}
|
|
1405
|
+
sp("tm", clock(e.t));
|
|
1406
|
+
sp("st", e.k);
|
|
1407
|
+
var bd = sp("bd", "");
|
|
1408
|
+
var ft = doc.createElement(CHECKS.indexOf(e.f) >= 0 ? "a" : "b");
|
|
1409
|
+
ft.className = "ft";
|
|
1410
|
+
ft.textContent = e.f;
|
|
1411
|
+
if (ft.tagName === "A") {
|
|
1412
|
+
ft.className = "ft lq";
|
|
1413
|
+
ft.href = showUrl(e.f);
|
|
1414
|
+
ft.target = "_blank";
|
|
1415
|
+
ft.rel = "noopener";
|
|
1416
|
+
ft.title = "What " + e.f + " checks";
|
|
1417
|
+
if (doc === document) ft.tabIndex = outT();
|
|
1418
|
+
}
|
|
1419
|
+
bd.appendChild(ft);
|
|
1420
|
+
bd.appendChild(doc.createTextNode(" "));
|
|
1421
|
+
if (wcagOf(e)) {
|
|
1422
|
+
var wc = doc.createElement("span");
|
|
1423
|
+
wc.className = "wc";
|
|
1424
|
+
wc.textContent = "WCAG " + wcagOf(e);
|
|
1425
|
+
bd.appendChild(wc);
|
|
1426
|
+
bd.appendChild(doc.createTextNode(" "));
|
|
1427
|
+
}
|
|
1428
|
+
e.p.forEach(function (x) {
|
|
1429
|
+
if (typeof x === "string") return bd.appendChild(doc.createTextNode(x));
|
|
1430
|
+
if (!x.n) return bd.appendChild(doc.createTextNode(partText(x)));
|
|
1431
|
+
var c = doc.createElement("button");
|
|
1432
|
+
c.type = "button";
|
|
1433
|
+
c.className = "lc";
|
|
1434
|
+
c.textContent = String(x.n);
|
|
1435
|
+
c.setAttribute("aria-label", "Go to stop " + x.n);
|
|
1436
|
+
if (doc === document) c.tabIndex = panelIn ? 0 : -1;
|
|
1437
|
+
c.addEventListener("click", function () {
|
|
1438
|
+
if (doc !== document && tabOpen() && window.name) logTab.open("", window.name);
|
|
1439
|
+
goTo(x.el);
|
|
1440
|
+
});
|
|
1441
|
+
bd.appendChild(c);
|
|
1442
|
+
bd.appendChild(doc.createTextNode(" \"" + x.l + "\""));
|
|
1443
|
+
});
|
|
1444
|
+
return li;
|
|
1445
|
+
}
|
|
1446
|
+
function logText() {
|
|
1447
|
+
var c = logCounts();
|
|
1448
|
+
var out = ["Tab trail " + VERSION + " log", addr(), stamp(), browser() + ", window " + innerWidth + " x " + innerHeight, pl(stops.length, "stop", "stops") + ", " + pl(c.bad, "problem", "problems") + ", " + c.ok + " OK, " + c.skip + " skipped", ""];
|
|
1449
|
+
logs.slice().reverse().forEach(function (e) {
|
|
1450
|
+
out.push(clock(e.t) + " " + (e.k + " ").slice(0, 8) + " " + e.f + (showWcag && wcagOf(e) ? " (WCAG " + wcagOf(e) + ")" : ""));
|
|
1451
|
+
out.push(" " + e.p.map(partText).join(""));
|
|
1452
|
+
});
|
|
1453
|
+
return out.join("\n");
|
|
1454
|
+
}
|
|
1455
|
+
var W_FORCE = "2.4.3 Focus Order (Level A). tabindex above 0 pulls it ahead of the page. It fails WCAG 2.4.3 when that order makes no sense (F44).", W_TRAP = "2.1.2 No Keyboard Trap (Level A)", W_KEY = "2.1.1 Keyboard (Level A)", W_VIS = "2.4.7 Focus Visible (Level AA)", W_ORDER = "2.4.3 Focus Order (Level A)", W_HIDE = "2.4.11 Focus Not Obscured (Minimum) (Level AA)";
|
|
1456
|
+
function cssId(t) { return /^[A-Za-z][\w-]*$/.test(t); }
|
|
1457
|
+
function sel(e) {
|
|
1458
|
+
if (!e || e.nodeType !== 1) return "";
|
|
1459
|
+
var rt = e.getRootNode(), live = e.isConnected, path = [];
|
|
1460
|
+
for (var n = e; n && n.nodeType === 1; n = n.parentElement) {
|
|
1461
|
+
var t = n.tagName.toLowerCase();
|
|
1462
|
+
if (n.id && cssId(n.id) && !secretish(n.id) && live && rt.querySelectorAll("#" + n.id).length === 1) {
|
|
1463
|
+
path.unshift("#" + n.id);
|
|
1464
|
+
break;
|
|
1465
|
+
}
|
|
1466
|
+
if (t === "html" || t === "body") {
|
|
1467
|
+
path.unshift(t);
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
var c = typeof n.className === "string" ? n.className.trim().split(/\s+/).filter(function (x) { return cssId(x) && !secretish(x); }).slice(0, 2) : [];
|
|
1471
|
+
var part = t + (c.length ? "." + c.join(".") : ""), par = n.parentElement;
|
|
1472
|
+
if (par) {
|
|
1473
|
+
var same = Array.prototype.filter.call(par.children, function (x) { return x.tagName === n.tagName; });
|
|
1474
|
+
if (same.length > 1) part += ":nth-of-type(" + (same.indexOf(n) + 1) + ")";
|
|
1475
|
+
}
|
|
1476
|
+
path.unshift(part);
|
|
1477
|
+
if (live) {
|
|
1478
|
+
try { if (rt.querySelectorAll(path.join(" > ")).length === 1) break; } catch (x) {}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
var out = path.join(" > ");
|
|
1482
|
+
if (rt && rt.host) out = sel(rt.host) + " (inside its shadow root) " + out;
|
|
1483
|
+
return out;
|
|
1484
|
+
}
|
|
1485
|
+
var KEEP = /^(id|class|role|type|name|href|src|tabindex|disabled|hidden|contenteditable|aria-[\w-]+)$/, VOID = /^(area|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/;
|
|
1486
|
+
function attrText(n, v) {
|
|
1487
|
+
if (n === "href" || n === "src") return cleanUrl(v);
|
|
1488
|
+
if (n === "id" || n === "class") return scrub(v);
|
|
1489
|
+
if (n === "role" || n === "type") return v;
|
|
1490
|
+
v = scrub(v);
|
|
1491
|
+
return v.length > 60 ? v.slice(0, 60) + "..." : v;
|
|
1492
|
+
}
|
|
1493
|
+
function snip(e, kids) {
|
|
1494
|
+
var tag = e.tagName.toLowerCase(), open = "<" + tag;
|
|
1495
|
+
[].forEach.call(e.attributes, function (a) {
|
|
1496
|
+
if (KEEP.test(a.name)) open += " " + a.name + "=\"" + attrText(a.name, a.value).replace(/"/g, """) + "\"";
|
|
1497
|
+
});
|
|
1498
|
+
open += ">";
|
|
1499
|
+
if (VOID.test(tag)) return open;
|
|
1500
|
+
if (kids && e.children.length) return open + [].slice.call(e.children, 0, 8).map(function (c) { return c.children.length ? snip(c).replace(/>[^<]*<\/[\w-]+>$/, ">...</" + c.tagName.toLowerCase() + ">") : snip(c); }).join("") + (e.children.length > 8 ? "..." : "") + "</" + tag + ">";
|
|
1501
|
+
var text = scrub((e.textContent || "").trim().replace(/\s+/g, " "));
|
|
1502
|
+
return open + (text.length > 40 ? text.slice(0, 40) + "..." : text) + "</" + tag + ">";
|
|
1503
|
+
}
|
|
1504
|
+
var FRAME = /^(__.*|SegmentViewNode|LayoutRouter.*|InnerLayoutRouter|OuterLayoutRouter|RenderFromTemplateContext|ScrollAndFocusHandler|InnerScrollAndFocusHandler|.*Boundary.*|HTTPAccessFallback.*|Router|AppRouter|HotReload|ReactDevOverlay|DevRootHTTPAccessFallbackBoundary|ServerRoot|Root|AppContainer|Suspense|Fragment|StrictMode|Head|Html|Body|Script|ClientPageRoot|ClientSegmentRoot|.*Provider|.*Context|.*Consumer|Link|LinkComponent|Image|ForwardRef|Memo|Anonymous|_c\d*)$/;
|
|
1505
|
+
function compOf(e) {
|
|
1506
|
+
var keys = Object.keys(e), k = keys.filter(function (x) { return x.indexOf("__reactFiber$") === 0 || x.indexOf("__reactInternalInstance$") === 0; })[0];
|
|
1507
|
+
if (k) {
|
|
1508
|
+
var names = [], src = "", any = false;
|
|
1509
|
+
for (var f = e[k]; f && names.length < 3; f = f.return) {
|
|
1510
|
+
var t = f.type;
|
|
1511
|
+
if (!src && f._debugSource && f._debugSource.fileName) src = f._debugSource.fileName + ":" + f._debugSource.lineNumber;
|
|
1512
|
+
if (!t || typeof t === "string" || typeof t === "symbol") continue;
|
|
1513
|
+
var n = t.displayName || t.name || (t.render && (t.render.displayName || t.render.name)) || (t.type && (t.type.displayName || t.type.name));
|
|
1514
|
+
if (!n) continue;
|
|
1515
|
+
any = true;
|
|
1516
|
+
if (FRAME.test(n) || names.indexOf(n) >= 0) continue;
|
|
1517
|
+
names.push(n);
|
|
1518
|
+
}
|
|
1519
|
+
if (!names.length) return any ? "React, rendered by a server component or by the framework itself, so its component name is not in the browser; search the code for the HTML or its classes" : "";
|
|
1520
|
+
if (names.every(function (n) { return n.length <= 2; })) return "React (component names are minified in this production build; a development build shows them)";
|
|
1521
|
+
return "React " + names[0] + (names.length > 1 ? ", inside " + names.slice(1).join(", inside ") : "") + (src ? ", source " + src : "");
|
|
1522
|
+
}
|
|
1523
|
+
if (e.__vueParentComponent) {
|
|
1524
|
+
var vn = [];
|
|
1525
|
+
for (var c = e.__vueParentComponent; c && vn.length < 3; c = c.parent) {
|
|
1526
|
+
var nm = c.type && (c.type.name || c.type.__name);
|
|
1527
|
+
if (nm && vn.indexOf(nm) < 0) vn.push(nm);
|
|
1528
|
+
}
|
|
1529
|
+
if (vn.length) return "Vue " + vn[0] + (vn.length > 1 ? ", inside " + vn.slice(1).join(", inside ") : "");
|
|
1530
|
+
}
|
|
1531
|
+
if (e.__vue__ && e.__vue__.$options && e.__vue__.$options.name) return "Vue " + e.__vue__.$options.name;
|
|
1532
|
+
try {
|
|
1533
|
+
var ng = window.ng;
|
|
1534
|
+
if (ng && ng.getOwningComponent) {
|
|
1535
|
+
var oc = ng.getOwningComponent(e);
|
|
1536
|
+
if (oc && oc.constructor) return "Angular " + oc.constructor.name;
|
|
1537
|
+
}
|
|
1538
|
+
} catch (x) {}
|
|
1539
|
+
return "";
|
|
1540
|
+
}
|
|
1541
|
+
function whereOf(el) {
|
|
1542
|
+
if (!el || !el.isConnected) return "";
|
|
1543
|
+
var out = [], up = el.parentElement;
|
|
1544
|
+
while (up && up !== document.body && up !== document.documentElement && !up.id) up = up.parentElement;
|
|
1545
|
+
if (up && up.id && up !== document.body) out.push("inside #" + scrub(up.id));
|
|
1546
|
+
var hs = document.querySelectorAll("h1,h2,h3,h4,h5,h6,[role=heading]"), last = null;
|
|
1547
|
+
for (var i = 0; i < hs.length; i++) {
|
|
1548
|
+
if (hs[i] === el || (host && host.contains(hs[i]))) continue;
|
|
1549
|
+
if (hs[i].contains(el) || hs[i].compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING) last = hs[i]; else break;
|
|
1550
|
+
}
|
|
1551
|
+
var t = last ? scrub((last.textContent || "").replace(/\s+/g, " ").trim()).slice(0, 60) : "";
|
|
1552
|
+
if (t) out.push("under the heading \"" + t + "\"");
|
|
1553
|
+
return out.join(", ");
|
|
1554
|
+
}
|
|
1555
|
+
function aiOf(crit, expect, fix, els, more, lazy) {
|
|
1556
|
+
function fact(x) {
|
|
1557
|
+
var o = { role: x[0], el: x[1] };
|
|
1558
|
+
function fill() {
|
|
1559
|
+
o.sel = x[2] ? x[2].sel : sel(x[1]);
|
|
1560
|
+
o.html = x[2] ? x[2].html : snip(x[1], x[3]);
|
|
1561
|
+
o.comp = compOf(x[1]);
|
|
1562
|
+
}
|
|
1563
|
+
if (!lazy) fill();
|
|
1564
|
+
else ["sel", "html", "comp"].forEach(function (k) {
|
|
1565
|
+
Object.defineProperty(o, k, { configurable: true, enumerable: true, get: function () { fill(); return o[k]; }, set: function (v) { Object.defineProperty(o, k, { value: v, writable: true, enumerable: true }); } });
|
|
1566
|
+
});
|
|
1567
|
+
return o;
|
|
1568
|
+
}
|
|
1569
|
+
return {
|
|
1570
|
+
crit: crit,
|
|
1571
|
+
expect: expect,
|
|
1572
|
+
fix: fix,
|
|
1573
|
+
more: more || [],
|
|
1574
|
+
els: els.filter(function (x) { return x[1]; }).map(fact)
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
function tally(k) {
|
|
1578
|
+
var m = {}, order = [];
|
|
1579
|
+
logs.forEach(function (e) {
|
|
1580
|
+
if (e.k !== k) return;
|
|
1581
|
+
if (!m[e.f]) {
|
|
1582
|
+
m[e.f] = 0;
|
|
1583
|
+
order.push(e.f);
|
|
1584
|
+
}
|
|
1585
|
+
m[e.f]++;
|
|
1586
|
+
});
|
|
1587
|
+
return order.map(function (f) { return f + " " + m[f]; }).join(", ");
|
|
1588
|
+
}
|
|
1589
|
+
function stamp() {
|
|
1590
|
+
var d = new Date();
|
|
1591
|
+
return d.getFullYear() + "-" + two(d.getMonth() + 1) + "-" + two(d.getDate()) + " " + two(d.getHours()) + ":" + two(d.getMinutes());
|
|
1592
|
+
}
|
|
1593
|
+
function verifyOf(e) {
|
|
1594
|
+
var a = e.ai, t = e.p.map(partText).join("");
|
|
1595
|
+
function el(r) {
|
|
1596
|
+
var x = a.els.filter(function (y) { return y.role === r; })[0];
|
|
1597
|
+
return x ? x.sel : "";
|
|
1598
|
+
}
|
|
1599
|
+
if (e.f === "Missed spots") return "Reload the page and run Tab trail again: " + el("Element") + " gets a stop number and the skipped count goes down by 1. Press Tab until it has focus, then Enter (and Space for a button) does what a click does.";
|
|
1600
|
+
if (e.f === "Forced order") return "Reload the page and run Tab trail again: " + el("Element") + " has no tabindex above 0, its stop number matches its place on the page, and the Forced order count goes down by 1.";
|
|
1601
|
+
if (e.f === "Hover menus") return "Press Tab until a link inside " + el("Element") + " has focus: the menu opens while focus is inside it, and Tab trail no longer lists it under hover menus.";
|
|
1602
|
+
if (e.f === "Hidden focus") return "Press Tab until " + el("Element") + " has focus: part of it shows next to " + el("Covered by") + ", and its Hidden focus line in the log says in view or partly covered.";
|
|
1603
|
+
if (e.f === "Keyboard trap") return "Put focus on " + el("Element") + " and press Tab: focus moves on to " + el("Expected next") + ", and the log shows an OK Out of order line.";
|
|
1604
|
+
if (e.f === "Lost focus") return "Open the popup from " + el("Opened by") + " with Enter, then close it with Escape or its close button: focus is back on " + el("Opened by") + ", and the log shows an OK Lost focus line.";
|
|
1605
|
+
if (el("Popup")) return "Reload so the popup shows, then press Tab once: focus lands inside " + el("Popup") + ".";
|
|
1606
|
+
return "Put focus on " + (el("Tab left from") || "the start of the page") + " and press " + (t.indexOf("(Shift+Tab)") >= 0 ? "Shift+Tab" : "Tab") + " once: focus lands on " + el("Expected next") + ", and the log shows an OK Out of order line.";
|
|
1607
|
+
}
|
|
1608
|
+
var hidTested = new Set();
|
|
1609
|
+
function coverage() {
|
|
1610
|
+
var out = [], left = stops.filter(function (x) { return !hidTested.has(x); }).map(function (x) { return stops.indexOf(x) + 1; });
|
|
1611
|
+
if (left.length) out.push("Hidden focus: " + left.length + " of " + pl(stops.length, "stop was", "stops were") + " never tested (" + left.slice(0, 30).join(", ") + (left.length > 30 ? " and " + (left.length - 30) + " more" : "") + "). Press Play to test every stop.");
|
|
1612
|
+
var presses = logs.filter(function (e) { return e.f === "Out of order" || e.f === "Keyboard trap"; }).length;
|
|
1613
|
+
out.push("Out of order and Keyboard trap: judged only for the " + pl(presses, "Tab press", "Tab presses") + " made in this run. Press Tab through the whole page, and Shift+Tab back, to judge every step.");
|
|
1614
|
+
var pops = logs.filter(function (e) { return e.f === "Lost focus"; }).length;
|
|
1615
|
+
out.push("Lost focus: " + (pops ? "only " + pl(pops, "popup was", "popups were") : "no popups were") + " opened and closed in this run. Open and close every popup, menu and dialog on the page to check them all.");
|
|
1616
|
+
out.push("Window size: everything was tested at " + innerWidth + " x " + innerHeight + " only. Sticky bars, menus and popups can behave differently on phones; run it again in a window about 390 px wide.");
|
|
1617
|
+
out.push("Not checked by Tab trail at all: whether the focus outline is visible and has enough contrast, accessible names of buttons and links, color contrast of text, what a screen reader announces, and content inside iframes. Use axe DevTools or Lighthouse for names, contrast and iframes. Check focus visibility with Spotlight and screen reader output with VoiceOver or NVDA.");
|
|
1618
|
+
return out;
|
|
1619
|
+
}
|
|
1620
|
+
var probLog = [], ignore = [], CAP = 200, judgedDir = {};
|
|
1621
|
+
function ignored(e) {
|
|
1622
|
+
return ignore.length && e.ai.els.some(function (x) {
|
|
1623
|
+
for (var n = x.el; n && n.nodeType === 1; n = n.parentElement || (n.getRootNode() && n.getRootNode().host)) {
|
|
1624
|
+
for (var i = 0; i < ignore.length; i++) if (n.matches(ignore[i])) return true;
|
|
1625
|
+
}
|
|
1626
|
+
return false;
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
function openProbs(all) {
|
|
1630
|
+
var seen = {}, out = [];
|
|
1631
|
+
probLog.forEach(function (e) {
|
|
1632
|
+
var t = e.f + e.p.map(partText).join("");
|
|
1633
|
+
if (e.fixed || seen[t]) return;
|
|
1634
|
+
seen[t] = 1;
|
|
1635
|
+
if (all || !ignored(e)) out.push(e);
|
|
1636
|
+
});
|
|
1637
|
+
return out;
|
|
1638
|
+
}
|
|
1639
|
+
function hash(t) {
|
|
1640
|
+
var h = 2166136261;
|
|
1641
|
+
for (var i = 0; i < t.length; i++) h = Math.imul(h ^ t.charCodeAt(i), 16777619);
|
|
1642
|
+
return ("0000000" + (h >>> 0).toString(16)).slice(-8);
|
|
1643
|
+
}
|
|
1644
|
+
function keyOf(e) {
|
|
1645
|
+
var t = e.tagName.toLowerCase();
|
|
1646
|
+
if (e.id && cssId(e.id)) return t + "#" + e.id;
|
|
1647
|
+
var up = "";
|
|
1648
|
+
for (var p = e.parentElement; p; p = p.parentElement) if (p.id && cssId(p.id)) { up = "#" + p.id + " "; break; }
|
|
1649
|
+
return up + t + (e.getAttribute("role") ? "[role=" + e.getAttribute("role") + "]" : "") + (e.getAttribute("name") ? "[name=" + e.getAttribute("name") + "]" : "") + "\"" + label(e) + "\"";
|
|
1650
|
+
}
|
|
1651
|
+
function mainEl(e) {
|
|
1652
|
+
var to = e.ai.els.filter(function (x) { return x.role === "Tab jumped to"; })[0];
|
|
1653
|
+
return to || e.ai.els[0];
|
|
1654
|
+
}
|
|
1655
|
+
function problemsOf(list) {
|
|
1656
|
+
var used = {};
|
|
1657
|
+
return list.map(function (e) {
|
|
1658
|
+
var m = mainEl(e), id = hash(e.f + "|" + e.ai.els.map(function (x) { return keyOf(x.el); }).join("|"));
|
|
1659
|
+
used[id] = (used[id] || 0) + 1;
|
|
1660
|
+
return { id: used[id] > 1 ? id + "-" + used[id] : id, check: e.f, wcag: wcagOf(e) || null, selector: m ? m.sel : null, html: m ? m.html : null, component: m && m.comp ? m.comp : null, fix: e.ai.fix, verify: verifyOf(e) };
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
function aiText() {
|
|
1664
|
+
var out = [], skips = [], seenS = {}, notes = [], probs = openProbs(), left = openProbs(true).length - probs.length, ids = problemsOf(probs), groups = [], byKey = {};
|
|
1665
|
+
probs.forEach(function (e, i) {
|
|
1666
|
+
var m = mainEl(e), k = /^(Missed spots|Hover menus|Forced order)$/.test(e.f) && m ? e.f + "|" + e.ai.fix + "|" + desc(m.el) + "|" + m.comp : "#" + i, g = byKey[k];
|
|
1667
|
+
if (!g) groups.push((g = byKey[k] = { i: i, list: [] }));
|
|
1668
|
+
g.list.push(e);
|
|
1669
|
+
});
|
|
1670
|
+
logs.forEach(function (e) {
|
|
1671
|
+
var t = e.p.map(partText).join("");
|
|
1672
|
+
if (e.k === "SKIPPED" && !seenS[e.f + t]) {
|
|
1673
|
+
seenS[e.f + t] = 1;
|
|
1674
|
+
skips.push(e.f + ": " + t);
|
|
1675
|
+
} else if (e.k === "INFO") notes.push(clock(e.t) + " " + e.f + ": " + t);
|
|
1676
|
+
});
|
|
1677
|
+
var c = logCounts();
|
|
1678
|
+
out.push("Tab trail " + VERSION + " report for an AI agent");
|
|
1679
|
+
out.push("Page: " + addr());
|
|
1680
|
+
out.push("Ran on: " + stamp() + ", " + browser() + ", window " + innerWidth + " x " + innerHeight);
|
|
1681
|
+
out.push("Tool: Tab trail (matjazkorosec.com/tools/tab-trail), a bookmarklet that checks the keyboard Tab order of the page. Stop numbers are positions in the Tab order when the check ran. Use the selectors, the HTML and the component names to find each element in the code.");
|
|
1682
|
+
out.push("Run it again from a script (for example Playwright): save https://raw.githubusercontent.com/matjazkorosec/tab-trail/v" + VERSION + "/dist/tab-trail.js in your repo once and load your saved copy with page.evaluate(readFileSync(...)), which works under a Content Security Policy. Then await window.__tabTrail.play() to walk every stop, and read window.__tabTrail.problems() for every open problem as data, window.__tabTrail.report() for this same report or window.__tabTrail.log() for every line.");
|
|
1683
|
+
out.push("");
|
|
1684
|
+
out.push("Summary: " + pl(probs.length, "problem", "problems") + " to fix" + (groups.length < probs.length ? " (" + pl(groups.length, "different fix", "different fixes") + ")" : "") + ". " + pl(c.ok, "check", "checks") + " passed, " + c.skip + " skipped.");
|
|
1685
|
+
if (walkEnd || walking) out.push("Play: " + playState() + ".");
|
|
1686
|
+
var pass = tally("OK"), sk = tally("SKIPPED");
|
|
1687
|
+
if (pass) out.push("Passed: " + pass + ".");
|
|
1688
|
+
if (sk) out.push("Skipped: " + sk + ".");
|
|
1689
|
+
var ran = ranChecks();
|
|
1690
|
+
if (ran.length) out.push("Checked: " + ran.join(", ") + ". Each check is explained at " + showUrl(ran[0]).replace(/#.*/, "#shows") + " under Fix what turns red.");
|
|
1691
|
+
if (left) out.push("Left out on purpose: " + pl(left, "problem", "problems") + " inside " + ignore.join(", ") + ".");
|
|
1692
|
+
if (groups.length > CAP) out.push("Showing the first " + CAP + " of " + groups.length.toLocaleString("en-US") + " problems. window.__tabTrail.problems() returns every one.");
|
|
1693
|
+
groups.slice(0, CAP).forEach(function (g, n) {
|
|
1694
|
+
var e = g.list[0], i = g.i, more = g.list.length - 2;
|
|
1695
|
+
out.push("");
|
|
1696
|
+
out.push("Problem " + (n + 1) + " of " + groups.length + ": " + e.f + (g.list.length > 1 ? ", " + g.list.length + " elements with the same cause: " + desc(mainEl(e).el) + " (" + g.list.slice(0, 2).map(function (x) { return "\"" + label(mainEl(x).el) + "\""; }).join(", ") + (more > 0 ? " and " + more + " more" : "") + "). Fix it once in the component that draws them." : "") + " (" + clock(e.t) + ")");
|
|
1697
|
+
out.push("Id: " + ids[i].id + (g.list.length > 1 ? " (the first of " + g.list.length + ", window.__tabTrail.problems() lists every one)" : ""));
|
|
1698
|
+
if (e.ai) out.push("WCAG: " + e.ai.crit);
|
|
1699
|
+
out.push("What happened: " + e.p.map(partText).join(""));
|
|
1700
|
+
if (!e.ai) return;
|
|
1701
|
+
out.push("Expected: " + e.ai.expect);
|
|
1702
|
+
e.ai.els.forEach(function (x) {
|
|
1703
|
+
out.push(x.role + ": " + x.sel + (x.el.isConnected ? "" : " (no longer on the page)"));
|
|
1704
|
+
out.push(" HTML: " + x.html);
|
|
1705
|
+
if (x.comp) out.push(" Component: " + x.comp);
|
|
1706
|
+
var where = whereOf(x.el);
|
|
1707
|
+
if (where) out.push(" Where: " + where);
|
|
1708
|
+
});
|
|
1709
|
+
e.ai.more.forEach(function (m) { out.push(m); });
|
|
1710
|
+
out.push("Fix hint: " + e.ai.fix);
|
|
1711
|
+
out.push("How to check the fix: " + verifyOf(e));
|
|
1712
|
+
if (CHECKS.indexOf(e.f) >= 0) out.push("About this check: " + showUrl(e.f));
|
|
1713
|
+
});
|
|
1714
|
+
out.push("");
|
|
1715
|
+
out.push("Not covered in this run:");
|
|
1716
|
+
coverage().forEach(function (t) { out.push("- " + t); });
|
|
1717
|
+
if (skips.length) {
|
|
1718
|
+
out.push("");
|
|
1719
|
+
out.push("Skipped checks, and why:");
|
|
1720
|
+
skips.slice(0, 12).forEach(function (t) { out.push("- " + t); });
|
|
1721
|
+
if (skips.length > 12) out.push("- and " + (skips.length - 12) + " more");
|
|
1722
|
+
}
|
|
1723
|
+
if (notes.length) {
|
|
1724
|
+
out.push("");
|
|
1725
|
+
out.push("Notes:");
|
|
1726
|
+
notes.slice(-10).forEach(function (t) { out.push("- " + t); });
|
|
1727
|
+
}
|
|
1728
|
+
return out.join("\n");
|
|
1729
|
+
}
|
|
1730
|
+
function copyIt(b, w, text, word) {
|
|
1731
|
+
var d = w.document;
|
|
1732
|
+
var lb = b.lastChild && b.lastChild.nodeType === 3 ? b.lastChild : b;
|
|
1733
|
+
function done(ok) {
|
|
1734
|
+
lb.textContent = ok ? "Copied" : "Copy failed";
|
|
1735
|
+
setTimeout(function () { lb.textContent = word; }, 1500);
|
|
1736
|
+
}
|
|
1737
|
+
function old() {
|
|
1738
|
+
var back = w === window ? deep() : d.activeElement;
|
|
1739
|
+
var ta = d.createElement("textarea");
|
|
1740
|
+
ta.value = text;
|
|
1741
|
+
ta.setAttribute("readonly", "");
|
|
1742
|
+
ta.style.cssText = "position:fixed;left:0;top:0;width:1px;height:1px;opacity:0";
|
|
1743
|
+
(w === window ? root : d.body).appendChild(ta);
|
|
1744
|
+
ta.focus({ preventScroll: true });
|
|
1745
|
+
ta.select();
|
|
1746
|
+
var ok = false;
|
|
1747
|
+
try { ok = d.execCommand("copy"); } catch (x) {}
|
|
1748
|
+
ta.remove();
|
|
1749
|
+
if (back && back.focus) back.focus({ preventScroll: true });
|
|
1750
|
+
done(ok);
|
|
1751
|
+
}
|
|
1752
|
+
if (w.navigator.clipboard && w.isSecureContext) w.navigator.clipboard.writeText(text).then(function () { done(true); }, old);
|
|
1753
|
+
else old();
|
|
1754
|
+
}
|
|
1755
|
+
function filters(parent, doc) {
|
|
1756
|
+
var row = doc.createElement("div");
|
|
1757
|
+
row.className = "lf";
|
|
1758
|
+
var set = FILT.map(function (f) {
|
|
1759
|
+
var b = doc.createElement("button");
|
|
1760
|
+
b.type = "button";
|
|
1761
|
+
b.className = "lt";
|
|
1762
|
+
b.addEventListener("click", function () {
|
|
1763
|
+
logFilter = f[0];
|
|
1764
|
+
logDraw();
|
|
1765
|
+
});
|
|
1766
|
+
row.appendChild(b);
|
|
1767
|
+
return b;
|
|
1768
|
+
});
|
|
1769
|
+
parent.appendChild(row);
|
|
1770
|
+
filterSets.push(set);
|
|
1771
|
+
return set;
|
|
1772
|
+
}
|
|
1773
|
+
function logSummary() {
|
|
1774
|
+
var c = logCounts();
|
|
1775
|
+
logSum.textContent = " " + pl(c.all, "event", "events");
|
|
1776
|
+
logBad.textContent = c.bad ? pl(c.bad, "problem", "problems") : "";
|
|
1777
|
+
logGroup.classList.toggle("warn", c.bad > 0);
|
|
1778
|
+
filterSets.forEach(function (set) {
|
|
1779
|
+
set.forEach(function (b, i) {
|
|
1780
|
+
b.textContent = FILT[i][1] + " " + c[FILT[i][0]];
|
|
1781
|
+
b.setAttribute("aria-pressed", logFilter === FILT[i][0] ? "true" : "false");
|
|
1782
|
+
b.classList.toggle("e", FILT[i][0] === "bad" && c.bad > 0);
|
|
1783
|
+
});
|
|
1784
|
+
});
|
|
1785
|
+
if (tabSum && tabOpen()) tabSum.textContent = addr() + ", " + pl(stops.length, "stop", "stops");
|
|
1786
|
+
checkedLine(logChecked, document);
|
|
1787
|
+
if (tabChecked && tabOpen()) checkedLine(tabChecked, logTab.document);
|
|
1788
|
+
if (sumLine && walkEnd === "done") sumDraw();
|
|
1789
|
+
}
|
|
1790
|
+
function logDraw() {
|
|
1791
|
+
if (logTab && logTab.closed) tabGone();
|
|
1792
|
+
logSummary();
|
|
1793
|
+
[logList, tabList].forEach(function (u) { if (u) while (u.firstChild) u.removeChild(u.firstChild); });
|
|
1794
|
+
logs.forEach(function (e) { e.li = null; });
|
|
1795
|
+
var away = tabOpen();
|
|
1796
|
+
logBody.hidden = !logOpen || away;
|
|
1797
|
+
logAway.hidden = !away;
|
|
1798
|
+
logBtn.setAttribute("aria-expanded", logBody.hidden ? "false" : "true");
|
|
1799
|
+
var v = logView();
|
|
1800
|
+
if (!v) return;
|
|
1801
|
+
var frag = v.ownerDocument.createDocumentFragment();
|
|
1802
|
+
logs.slice().reverse().forEach(function (e) {
|
|
1803
|
+
if (!shows(e)) return;
|
|
1804
|
+
e.li = logLi(e, v.ownerDocument);
|
|
1805
|
+
frag.appendChild(e.li);
|
|
1806
|
+
});
|
|
1807
|
+
v.appendChild(frag);
|
|
1808
|
+
toTop(v);
|
|
1809
|
+
}
|
|
1810
|
+
function tabGone() {
|
|
1811
|
+
logTab = null;
|
|
1812
|
+
tabList = null;
|
|
1813
|
+
tabSum = null;
|
|
1814
|
+
tabChecked = null;
|
|
1815
|
+
wcagBoxes = wcagBoxes.filter(function (b) { return b.ownerDocument === document; });
|
|
1816
|
+
tabNote = null;
|
|
1817
|
+
filterSets = filterSets.filter(function (x) { return x !== tabSet; });
|
|
1818
|
+
tabSet = null;
|
|
1819
|
+
if (tabPoll) clearInterval(tabPoll);
|
|
1820
|
+
tabPoll = 0;
|
|
1821
|
+
}
|
|
1822
|
+
var TAB_CSS = [
|
|
1823
|
+
"body{margin:0;padding:12px;background:#e4dccd;color:#1a1612;font:15px/1.5 -apple-system,system-ui,'Segoe UI',Roboto,sans-serif}",
|
|
1824
|
+
".hd,.box{box-sizing:border-box;max-width:1200px;margin:0 auto;background:#fbf8f3;border-radius:12px}",
|
|
1825
|
+
".wide .hd,.wide .box{max-width:none}",
|
|
1826
|
+
".fw{display:inline-grid;place-items:center;width:34px;height:34px;padding:0;border:1.5px solid #1a1612;border-radius:8px;background:#fff;color:#1a1612;cursor:pointer;box-sizing:border-box}",
|
|
1827
|
+
".fw:hover{background:#efe8dc}",
|
|
1828
|
+
".fw:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
1829
|
+
".fw .in,.wide .fw .out{display:none}",
|
|
1830
|
+
".wide .fw .in{display:inline}",
|
|
1831
|
+
".hd{position:sticky;top:12px;z-index:1;display:flex;flex-wrap:wrap;align-items:center;gap:10px 8px;padding:14px 18px;box-shadow:0 0 0 12px #e4dccd}",
|
|
1832
|
+
".box{margin-top:8px;padding:12px 0 8px;overflow:hidden}",
|
|
1833
|
+
"h1{margin:0;font:700 22px/1.2 Georgia,serif}",
|
|
1834
|
+
".u{margin:0 auto 0 6px;color:#5f564c}",
|
|
1835
|
+
".nt{flex-basis:100%;margin:0;color:#d0103a;font-weight:700}",
|
|
1836
|
+
".nt[hidden]{display:none}",
|
|
1837
|
+
".lf{display:inline-grid;grid-auto-flow:column;gap:2px;padding:3px;background:#efe8dc;border-radius:10px;margin-right:14px}",
|
|
1838
|
+
".fr{flex-basis:100%;display:flex;flex-wrap:wrap;align-items:center;gap:8px 0}",
|
|
1839
|
+
".lt,.kl,.ka,.lo,.lc{font:inherit;color:inherit;cursor:pointer}",
|
|
1840
|
+
".lt{padding:3px 14px;border:0;border-radius:7px;background:none;color:#5f564c;font-weight:600;font-size:14px}",
|
|
1841
|
+
".lt:hover{color:#1a1612;background:rgba(26,22,18,.06)}",
|
|
1842
|
+
".lt[aria-pressed=true]{background:#fff;color:#1a1612;box-shadow:0 1px 2px rgba(26,22,18,.2)}",
|
|
1843
|
+
".lt.e{color:#d0103a}",
|
|
1844
|
+
".lt.e:hover{background:rgba(208,16,58,.1)}",
|
|
1845
|
+
".lt.e[aria-pressed=true]{background:#d0103a;color:#fff}",
|
|
1846
|
+
".kl,.ka,.lo{display:inline-flex;align-items:center;gap:7px;height:34px;padding:0 14px;border-radius:8px;font-weight:700;font-size:14px;white-space:nowrap;box-sizing:border-box}",
|
|
1847
|
+
".kl,.lo{border:1.5px solid #1a1612;background:#fff;color:#1a1612}",
|
|
1848
|
+
".kl:hover,.lo:hover{background:#efe8dc}",
|
|
1849
|
+
".ka{border:0;background:#1a1612;color:#fbf8f3}",
|
|
1850
|
+
".ka:hover{background:#3a332c}",
|
|
1851
|
+
".lo{font-weight:600}",
|
|
1852
|
+
".lt:focus-visible,.kl:focus-visible,.ka:focus-visible,.lo:focus-visible,.lc:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
1853
|
+
".lck{margin:0;padding:0 18px 8px}",
|
|
1854
|
+
".lck[hidden]{display:none}",
|
|
1855
|
+
".lq{color:#1e3a8a;font-weight:700;text-decoration:none}",
|
|
1856
|
+
".lq:hover{text-decoration:underline;text-underline-offset:2px}",
|
|
1857
|
+
".wc{color:#1f7a3f;font-weight:400}",
|
|
1858
|
+
".nw .wc{display:none}",
|
|
1859
|
+
".lw{display:inline-flex;align-items:center;gap:8px;font-size:14px;color:#1f7a3f;cursor:pointer}",
|
|
1860
|
+
".lw input{width:16px;height:16px;margin:0;accent-color:#c2410c;cursor:pointer}",
|
|
1861
|
+
".lw input:focus-visible{outline:3px solid #c2410c;outline-offset:2px}",
|
|
1862
|
+
".lq.bad{color:#d0103a}",
|
|
1863
|
+
".lq:focus-visible{outline:3px solid #c2410c;outline-offset:2px;border-radius:2px}",
|
|
1864
|
+
".ll{list-style:none;margin:0;padding:0}",
|
|
1865
|
+
".lx{display:grid;grid-template-columns:72px 80px 1fr;gap:2px 12px;padding:6px 18px;align-items:baseline}",
|
|
1866
|
+
".lx:hover{background:#f3ede3}",
|
|
1867
|
+
".lx .bd{min-width:0;overflow-wrap:anywhere}",
|
|
1868
|
+
".lx.bad{background:rgba(208,16,58,.07)}",
|
|
1869
|
+
".tm,.st{font:500 14px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#5f564c}",
|
|
1870
|
+
".st{font-weight:700}",
|
|
1871
|
+
".ok .st{color:#1f7a3f}.bad .st{color:#d0103a}.skip .st{color:#5f564c}.info .st{color:#1e3a8a}",
|
|
1872
|
+
".ft{color:#1e3a8a}.bad .ft{color:#d0103a}",
|
|
1873
|
+
".lc{display:inline-block;min-width:24px;padding:0 6px;border:1px dashed #1a1612;border-radius:999px;background:none;font-size:14px;line-height:1.4;text-align:center}",
|
|
1874
|
+
".lc:hover{background:rgba(26,22,18,.08)}"
|
|
1875
|
+
].join("");
|
|
1876
|
+
var ownName = false, tabWide = false;
|
|
1877
|
+
function openTab() {
|
|
1878
|
+
var w = window.open("", "_blank");
|
|
1879
|
+
if (!w) {
|
|
1880
|
+
tabMsg.hidden = false;
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
tabMsg.hidden = true;
|
|
1884
|
+
logTab = w;
|
|
1885
|
+
if (!window.name) {
|
|
1886
|
+
window.name = "tab-trail-" + Date.now();
|
|
1887
|
+
ownName = true;
|
|
1888
|
+
}
|
|
1889
|
+
var d = w.document;
|
|
1890
|
+
d.title = "Tab trail log: " + location.host;
|
|
1891
|
+
try {
|
|
1892
|
+
var tsh = new w.CSSStyleSheet();
|
|
1893
|
+
tsh.replaceSync(TAB_CSS);
|
|
1894
|
+
d.adoptedStyleSheets = [tsh];
|
|
1895
|
+
} catch (e) {
|
|
1896
|
+
var st = d.createElement("style");
|
|
1897
|
+
st.textContent = TAB_CSS;
|
|
1898
|
+
d.head.appendChild(st);
|
|
1899
|
+
}
|
|
1900
|
+
var hd = d.createElement("div");
|
|
1901
|
+
hd.className = "hd";
|
|
1902
|
+
var h1 = d.createElement("h1");
|
|
1903
|
+
h1.textContent = "Tab trail log";
|
|
1904
|
+
hd.appendChild(h1);
|
|
1905
|
+
tabSum = d.createElement("p");
|
|
1906
|
+
tabSum.className = "u";
|
|
1907
|
+
hd.appendChild(tabSum);
|
|
1908
|
+
var cp = d.createElement("button");
|
|
1909
|
+
cp.type = "button";
|
|
1910
|
+
cp.className = "kl";
|
|
1911
|
+
icon(cp, 16, COPY_ICON, 1.6);
|
|
1912
|
+
cp.appendChild(d.createTextNode("Copy log"));
|
|
1913
|
+
cp.addEventListener("click", function () { copyIt(cp, w, logText(), "Copy log"); });
|
|
1914
|
+
hd.appendChild(cp);
|
|
1915
|
+
var ca = d.createElement("button");
|
|
1916
|
+
ca.type = "button";
|
|
1917
|
+
ca.className = "ka";
|
|
1918
|
+
icon(ca, 16, AI_ICON, 1.6);
|
|
1919
|
+
ca.appendChild(d.createTextNode("Copy for AI"));
|
|
1920
|
+
ca.addEventListener("click", function () { copyIt(ca, w, aiText(), "Copy for AI"); });
|
|
1921
|
+
hd.appendChild(ca);
|
|
1922
|
+
var bk = d.createElement("button");
|
|
1923
|
+
bk.type = "button";
|
|
1924
|
+
bk.className = "lo";
|
|
1925
|
+
bk.textContent = "Put back in panel";
|
|
1926
|
+
bk.addEventListener("click", putBack);
|
|
1927
|
+
hd.appendChild(bk);
|
|
1928
|
+
var fw = d.createElement("button");
|
|
1929
|
+
fw.type = "button";
|
|
1930
|
+
fw.className = "fw";
|
|
1931
|
+
fw.setAttribute("aria-label", "Full width");
|
|
1932
|
+
fw.title = "Full width";
|
|
1933
|
+
fw.setAttribute("aria-pressed", tabWide ? "true" : "false");
|
|
1934
|
+
icon(fw, 16, "M1.5 8h13M1.5 8l3-3M1.5 8l3 3M14.5 8l-3-3M14.5 8l-3 3", 1.6).setAttribute("class", "out");
|
|
1935
|
+
icon(fw, 16, "M1.5 8h4.5M6 8l-3-3M6 8l-3 3M14.5 8H10M10 8l3-3M10 8l3 3", 1.6).setAttribute("class", "in");
|
|
1936
|
+
fw.addEventListener("click", function () {
|
|
1937
|
+
tabWide = !tabWide;
|
|
1938
|
+
d.body.classList.toggle("wide", tabWide);
|
|
1939
|
+
fw.setAttribute("aria-pressed", tabWide ? "true" : "false");
|
|
1940
|
+
});
|
|
1941
|
+
hd.appendChild(fw);
|
|
1942
|
+
d.body.classList.toggle("wide", tabWide);
|
|
1943
|
+
tabNote = d.createElement("p");
|
|
1944
|
+
tabNote.className = "nt";
|
|
1945
|
+
tabNote.textContent = "Tab trail was closed on the page. This log no longer updates.";
|
|
1946
|
+
tabNote.hidden = true;
|
|
1947
|
+
hd.appendChild(tabNote);
|
|
1948
|
+
var fr = d.createElement("div");
|
|
1949
|
+
fr.className = "fr";
|
|
1950
|
+
hd.appendChild(fr);
|
|
1951
|
+
tabSet = filters(fr, d);
|
|
1952
|
+
wcagBox(fr, d);
|
|
1953
|
+
d.body.appendChild(hd);
|
|
1954
|
+
d.body.classList.toggle("nw", !showWcag);
|
|
1955
|
+
var bd = d.createElement("div");
|
|
1956
|
+
bd.className = "box";
|
|
1957
|
+
d.body.appendChild(bd);
|
|
1958
|
+
tabChecked = d.createElement("p");
|
|
1959
|
+
tabChecked.className = "lck";
|
|
1960
|
+
bd.appendChild(tabChecked);
|
|
1961
|
+
tabList = d.createElement("ul");
|
|
1962
|
+
tabList.className = "ll";
|
|
1963
|
+
bd.appendChild(tabList);
|
|
1964
|
+
tabPoll = setInterval(function () {
|
|
1965
|
+
if (logTab && logTab.closed) {
|
|
1966
|
+
tabGone();
|
|
1967
|
+
logDraw();
|
|
1968
|
+
}
|
|
1969
|
+
}, 1000);
|
|
1970
|
+
logOpen = true;
|
|
1971
|
+
logDraw();
|
|
1972
|
+
}
|
|
1973
|
+
function putBack() {
|
|
1974
|
+
var w = logTab;
|
|
1975
|
+
tabGone();
|
|
1976
|
+
logOpen = true;
|
|
1977
|
+
logDraw();
|
|
1978
|
+
if (w && !w.closed) w.close();
|
|
1979
|
+
}
|
|
1980
|
+
function lbtn(cls, text, parent) {
|
|
1981
|
+
var b = document.createElement("button");
|
|
1982
|
+
b.type = "button";
|
|
1983
|
+
b.className = cls;
|
|
1984
|
+
b.textContent = text;
|
|
1985
|
+
parent.appendChild(b);
|
|
1986
|
+
return b;
|
|
1987
|
+
}
|
|
1988
|
+
var logGroup = document.createElement("div");
|
|
1989
|
+
logGroup.className = "lgp";
|
|
1990
|
+
var logBtn = document.createElement("button");
|
|
1991
|
+
logBtn.type = "button";
|
|
1992
|
+
logBtn.className = "sg";
|
|
1993
|
+
logBtn.setAttribute("aria-expanded", "false");
|
|
1994
|
+
var logWord = document.createElement("b");
|
|
1995
|
+
logWord.textContent = "Log";
|
|
1996
|
+
icon(logBtn, 16, "M4 1.5h8v13H4zM6.5 5h3M6.5 8h3M6.5 11h2", 1.6);
|
|
1997
|
+
logBtn.appendChild(logWord);
|
|
1998
|
+
var logSum = document.createElement("span");
|
|
1999
|
+
logSum.className = "ls";
|
|
2000
|
+
var logBad = document.createElement("span");
|
|
2001
|
+
logBad.className = "bg";
|
|
2002
|
+
var logInfo = document.createElement("span");
|
|
2003
|
+
logInfo.appendChild(logSum);
|
|
2004
|
+
logBtn.appendChild(logInfo);
|
|
2005
|
+
logBtn.appendChild(logBad);
|
|
2006
|
+
logBtn.appendChild(document.createElement("i"));
|
|
2007
|
+
logGroup.appendChild(logBtn);
|
|
2008
|
+
var logBody = document.createElement("div");
|
|
2009
|
+
logBody.className = "lbd";
|
|
2010
|
+
logBody.hidden = true;
|
|
2011
|
+
logGroup.appendChild(logBody);
|
|
2012
|
+
var logTop = document.createElement("div");
|
|
2013
|
+
logTop.className = "lr lrt";
|
|
2014
|
+
logBody.appendChild(logTop);
|
|
2015
|
+
var logChecked = document.createElement("p");
|
|
2016
|
+
logChecked.className = "lck";
|
|
2017
|
+
logChecked.hidden = true;
|
|
2018
|
+
logBody.appendChild(logChecked);
|
|
2019
|
+
filters(logBody, document);
|
|
2020
|
+
wcagBox(logBody, document);
|
|
2021
|
+
var logList = document.createElement("ul");
|
|
2022
|
+
logList.className = "ll";
|
|
2023
|
+
logBody.appendChild(logList);
|
|
2024
|
+
var logRow = document.createElement("div");
|
|
2025
|
+
logRow.className = "lr lb2";
|
|
2026
|
+
logBody.appendChild(logRow);
|
|
2027
|
+
var copyBtn = lbtn("kl", "Copy log", logRow);
|
|
2028
|
+
copyBtn.insertBefore(icon(copyBtn, 16, COPY_ICON, 1.6), copyBtn.firstChild);
|
|
2029
|
+
copyBtn.addEventListener("click", function () { copyIt(copyBtn, window, logText(), "Copy log"); });
|
|
2030
|
+
var aiLog = lbtn("ka", "Copy for AI", logRow);
|
|
2031
|
+
aiLog.insertBefore(icon(aiLog, 16, AI_ICON, 1.6), aiLog.firstChild);
|
|
2032
|
+
aiLog.addEventListener("click", function () { copyIt(aiLog, window, aiText(), "Copy for AI"); });
|
|
2033
|
+
function newTabBtn(parent) {
|
|
2034
|
+
var b = lbtn("lnt", "", parent);
|
|
2035
|
+
icon(b, 14, "M9 2.5h4.5V7M13.5 2.5L7.5 8.5M12 9.5v4h-9.5v-9.5h4", 1.6);
|
|
2036
|
+
b.appendChild(document.createTextNode("Open log in new tab"));
|
|
2037
|
+
b.addEventListener("click", openTab);
|
|
2038
|
+
return b;
|
|
2039
|
+
}
|
|
2040
|
+
newTabBtn(logTop);
|
|
2041
|
+
var logEnd = document.createElement("div");
|
|
2042
|
+
logEnd.className = "lr";
|
|
2043
|
+
logBody.insertBefore(logEnd, logRow.nextSibling);
|
|
2044
|
+
newTabBtn(logEnd);
|
|
2045
|
+
var tabMsg = document.createElement("p");
|
|
2046
|
+
tabMsg.className = "lm";
|
|
2047
|
+
tabMsg.textContent = "The browser blocked the new tab. Allow pop-ups for this site and try again.";
|
|
2048
|
+
tabMsg.hidden = true;
|
|
2049
|
+
logBody.insertBefore(tabMsg, logChecked);
|
|
2050
|
+
var logAway = document.createElement("div");
|
|
2051
|
+
logAway.className = "la";
|
|
2052
|
+
logAway.hidden = true;
|
|
2053
|
+
var awayText = document.createElement("p");
|
|
2054
|
+
awayText.textContent = "The log is open in a new tab.";
|
|
2055
|
+
logAway.appendChild(awayText);
|
|
2056
|
+
var awayRow = document.createElement("div");
|
|
2057
|
+
awayRow.className = "lr";
|
|
2058
|
+
logAway.appendChild(awayRow);
|
|
2059
|
+
lbtn("lo", "Show it", awayRow).addEventListener("click", function () { if (tabOpen()) logTab.focus(); });
|
|
2060
|
+
lbtn("lo", "Put it back", awayRow).addEventListener("click", putBack);
|
|
2061
|
+
logGroup.appendChild(logAway);
|
|
2062
|
+
logBtn.addEventListener("click", function () {
|
|
2063
|
+
if (tabOpen()) return logTab.focus();
|
|
2064
|
+
logOpen = !logOpen;
|
|
2065
|
+
logDraw();
|
|
2066
|
+
if (!logOpen) return;
|
|
2067
|
+
var gr = logGroup.getBoundingClientRect(), pr = panel.getBoundingClientRect();
|
|
2068
|
+
if (gr.bottom > pr.bottom) panel.scrollTop += Math.min(gr.bottom - pr.bottom, gr.top - pr.top);
|
|
2069
|
+
});
|
|
2070
|
+
tray.insertBefore(logGroup, tray.firstChild);
|
|
2071
|
+
logGroup.className = "lgp sec";
|
|
2072
|
+
[[legendBtn, legend], [keysBtn, keysBox], [gear, settings]].forEach(function (p) {
|
|
2073
|
+
var w = document.createElement("div");
|
|
2074
|
+
w.className = "sec";
|
|
2075
|
+
tray.insertBefore(w, p[0]);
|
|
2076
|
+
w.appendChild(p[0]);
|
|
2077
|
+
w.appendChild(p[1]);
|
|
2078
|
+
});
|
|
2079
|
+
[logBtn, legendBtn, keysBtn, gear].forEach(function (b) {
|
|
2080
|
+
var g = b.querySelector("svg"), t = document.createElement("span");
|
|
2081
|
+
t.className = "ic";
|
|
2082
|
+
b.insertBefore(t, g);
|
|
2083
|
+
t.appendChild(g);
|
|
2084
|
+
});
|
|
2085
|
+
wcagSync();
|
|
2086
|
+
logSummary();
|
|
2087
|
+
root.appendChild(panel);
|
|
2088
|
+
skipPanel();
|
|
2089
|
+
var closed = false;
|
|
2090
|
+
function place() {
|
|
2091
|
+
if (closed) return;
|
|
2092
|
+
var m = modal(), to = m || document.documentElement;
|
|
2093
|
+
if (host.parentNode !== to) to.appendChild(host);
|
|
2094
|
+
var want = { position: m ? "fixed" : "absolute", left: m ? -scrollX + "px" : "0px", top: m ? -scrollY + "px" : "0px" };
|
|
2095
|
+
for (var k in want) if (host.style[k] !== want[k]) host.style[k] = want[k];
|
|
2096
|
+
}
|
|
2097
|
+
place();
|
|
2098
|
+
|
|
2099
|
+
function el(name, attrs, parent) {
|
|
2100
|
+
var n = document.createElementNS(NS, name);
|
|
2101
|
+
for (var k in attrs) n.setAttribute(k, attrs[k]);
|
|
2102
|
+
parent.appendChild(n);
|
|
2103
|
+
return n;
|
|
2104
|
+
}
|
|
2105
|
+
var queued = false, onlyScreen = true, boxKey = [];
|
|
2106
|
+
var current = -1;
|
|
2107
|
+
var pinned = new WeakMap();
|
|
2108
|
+
function isPinned(e) {
|
|
2109
|
+
if (pinned.has(e)) return pinned.get(e);
|
|
2110
|
+
var p = false;
|
|
2111
|
+
for (var n = e; n && n.nodeType === 1; n = n.parentElement || (n.getRootNode() && n.getRootNode().host)) {
|
|
2112
|
+
var pos = getComputedStyle(n).position;
|
|
2113
|
+
if (pos === "fixed" || pos === "sticky") { p = true; break; }
|
|
2114
|
+
}
|
|
2115
|
+
pinned.set(e, p);
|
|
2116
|
+
return p;
|
|
2117
|
+
}
|
|
2118
|
+
function clear(g) { while (g.firstChild) g.removeChild(g.firstChild); }
|
|
2119
|
+
var spotEl = null;
|
|
2120
|
+
function lit(r) {
|
|
2121
|
+
clear(spot);
|
|
2122
|
+
if (!light.checked) return;
|
|
2123
|
+
var W = innerWidth, H = innerHeight, d = "M0 0H" + W + "V" + H + "H0Z";
|
|
2124
|
+
if (r && (r.width || r.height)) {
|
|
2125
|
+
var x0 = r.left - 6, y0 = r.top - 6, x1 = r.right + 6, y1 = r.bottom + 6, k = Math.min(8, (x1 - x0) / 2, (y1 - y0) / 2);
|
|
2126
|
+
d += "M" + (x0 + k) + " " + y0 + "H" + (x1 - k) + "A" + k + " " + k + " 0 0 1 " + x1 + " " + (y0 + k) + "V" + (y1 - k) + "A" + k + " " + k + " 0 0 1 " + (x1 - k) + " " + y1 + "H" + (x0 + k) + "A" + k + " " + k + " 0 0 1 " + x0 + " " + (y1 - k) + "V" + (y0 + k) + "A" + k + " " + k + " 0 0 1 " + (x0 + k) + " " + y0 + "Z";
|
|
2127
|
+
}
|
|
2128
|
+
el("path", { d: d, fill: "rgba(15,12,10,.72)", "fill-rule": "evenodd" }, spot);
|
|
2129
|
+
}
|
|
2130
|
+
function box(m, r, layer) {
|
|
2131
|
+
if (m === shownEl) {
|
|
2132
|
+
el("rect", { x: r.left - 6, y: r.top - 6, width: r.width + 12, height: r.height + 12, fill: "none", stroke: "#fff", "stroke-width": 8, rx: 6 }, layer);
|
|
2133
|
+
el("rect", { x: r.left - 6, y: r.top - 6, width: r.width + 12, height: r.height + 12, fill: "none", stroke: "#d0103a", "stroke-width": 4, rx: 6 }, layer);
|
|
2134
|
+
}
|
|
2135
|
+
el("rect", { x: r.left, y: r.top, width: r.width, height: r.height, fill: "rgba(208,16,58,.12)", stroke: "#d0103a", "stroke-width": 3, "stroke-dasharray": "7 5", rx: 3 }, layer);
|
|
2136
|
+
}
|
|
2137
|
+
function trailLine(pts, layer) {
|
|
2138
|
+
if (pts.length < 2) return;
|
|
2139
|
+
var p = pts.map(function (q) { return q[0] + "," + q[1]; }).join(" ");
|
|
2140
|
+
el("polyline", { points: p, fill: "none", stroke: "#fff", "stroke-width": 6, "stroke-linejoin": "round", "stroke-linecap": "round", opacity: 0.9 }, layer);
|
|
2141
|
+
el("polyline", { points: p, fill: "none", stroke: "#ff8f57", "stroke-width": 3, "stroke-linejoin": "round", "stroke-linecap": "round" }, layer);
|
|
2142
|
+
}
|
|
2143
|
+
function dotsIn(list, layer) {
|
|
2144
|
+
list.sort(function (a, b) { return (a[2] - 1 === current) - (b[2] - 1 === current); });
|
|
2145
|
+
list.forEach(function (d) {
|
|
2146
|
+
var big = d[2] > 99, on = d[2] - 1 === current;
|
|
2147
|
+
var g = el("g", { class: "o", "data-i": d[2] - 1 }, layer);
|
|
2148
|
+
if (on) el("circle", { cx: d[0], cy: d[1], r: big ? 19 : 17, fill: "none", stroke: "#ff8f57", "stroke-width": 4 }, g);
|
|
2149
|
+
if (d[3] && !on) el("circle", { cx: d[0], cy: d[1], r: big ? 14 : 12, fill: "#fff", stroke: "#1a1612", "stroke-width": 2, "stroke-dasharray": "4 3" }, g);
|
|
2150
|
+
else el("circle", { cx: d[0], cy: d[1], r: big ? 14 : 12, fill: on ? "#c2410c" : "#1a1612", stroke: "#fff", "stroke-width": 2 }, g);
|
|
2151
|
+
var t = el("text", { x: d[0], y: d[1] + 0.5, fill: d[3] && !on ? "#1a1612" : "#fff", "font-size": big ? 10 : 11, "font-weight": 700, "font-family": "system-ui,sans-serif", "text-anchor": "middle", "dominant-baseline": "middle" }, g);
|
|
2152
|
+
t.textContent = d[2];
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
function shortLines(pts, sx, sy) {
|
|
2156
|
+
var W = innerWidth, H = innerHeight, MAX = 100;
|
|
2157
|
+
var v = pts.map(function (p) { return p[2] ? [p[0], p[1]] : [p[0] - sx, p[1] - sy]; });
|
|
2158
|
+
function on(p) { return p[0] >= 0 && p[0] <= W && p[1] >= 0 && p[1] <= H; }
|
|
2159
|
+
function arrow(from, to, L) {
|
|
2160
|
+
var dx = to[0] - from[0], dy = to[1] - from[1], len = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
2161
|
+
var ux = dx / len, uy = dy / len;
|
|
2162
|
+
var tip = [from[0] + ux * L, from[1] + uy * L];
|
|
2163
|
+
trailLine([from, tip], svg);
|
|
2164
|
+
var pts3 = [[tip[0] + ux * 6, tip[1] + uy * 6], [tip[0] - ux * 9 + uy * 9, tip[1] - uy * 9 - ux * 9], [tip[0] - ux * 9 - uy * 9, tip[1] - uy * 9 + ux * 9]];
|
|
2165
|
+
el("polygon", { points: pts3.map(function (q) { return q[0] + "," + q[1]; }).join(" "), fill: "#ff8f57", stroke: "#fff", "stroke-width": 2, "stroke-linejoin": "round" }, svg);
|
|
2166
|
+
}
|
|
2167
|
+
for (var k = 1; k < v.length; k++) {
|
|
2168
|
+
var a = v[k - 1], b = v[k], ia = on(a), ib = on(b);
|
|
2169
|
+
var len = Math.sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1]));
|
|
2170
|
+
if (ia && ib && len <= MAX) trailLine([a, b], svg);
|
|
2171
|
+
else if (ia && ib) {
|
|
2172
|
+
var L = Math.min(MAX - 6, len / 2 - 12);
|
|
2173
|
+
arrow(a, b, L);
|
|
2174
|
+
arrow(b, a, L);
|
|
2175
|
+
}
|
|
2176
|
+
else if (ia || ib) arrow(ia ? a : b, ia ? b : a, Math.min(MAX - 6, len));
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
function draw() {
|
|
2180
|
+
queued = false;
|
|
2181
|
+
var page = !onlyScreen;
|
|
2182
|
+
onlyScreen = true;
|
|
2183
|
+
var sx = scrollX, sy = scrollY;
|
|
2184
|
+
var last = Math.max(Math.ceil(stops.length / PAGE) - 1, 0);
|
|
2185
|
+
if (win > last) win = last;
|
|
2186
|
+
var lo = paged() ? win * PAGE : 0, hi = paged() ? Math.min(lo + PAGE, stops.length) : stops.length;
|
|
2187
|
+
var red = [], at = [];
|
|
2188
|
+
missed.concat(hovers).forEach(function (m) {
|
|
2189
|
+
var p = isPinned(m);
|
|
2190
|
+
if (p || page) red.push([m, m.getBoundingClientRect(), p]);
|
|
2191
|
+
});
|
|
2192
|
+
for (var i = lo; i < hi; i++) {
|
|
2193
|
+
var sr = stops[i].getBoundingClientRect(), st = sr.width < 2 && sr.height < 2;
|
|
2194
|
+
at.push([sr, st, st || isPinned(stops[i])]);
|
|
2195
|
+
}
|
|
2196
|
+
var fr = shownEl && hovers.indexOf(shownEl) < 0 && forced.indexOf(shownEl) >= 0 ? [shownEl.getBoundingClientRect(), isPinned(shownEl)] : null;
|
|
2197
|
+
var lr = light.checked && spotEl && spotEl.isConnected ? spotEl.getBoundingClientRect() : null;
|
|
2198
|
+
var key = [shownEl];
|
|
2199
|
+
red.forEach(function (x) { if (!x[2]) key.push(x[0], x[1].left + sx, x[1].top + sy, x[1].width, x[1].height); });
|
|
2200
|
+
if (fr && !fr[1]) key.push(fr[0].left + sx, fr[0].top + sy, fr[0].width, fr[0].height);
|
|
2201
|
+
var keep = page && same(key, boxKey);
|
|
2202
|
+
if (page) boxKey = key;
|
|
2203
|
+
clear(svg);
|
|
2204
|
+
clear(dot);
|
|
2205
|
+
clear(under);
|
|
2206
|
+
lit(lr);
|
|
2207
|
+
if (page) {
|
|
2208
|
+
clear(svgPg);
|
|
2209
|
+
clear(dotPg);
|
|
2210
|
+
if (!keep) clear(underPg);
|
|
2211
|
+
}
|
|
2212
|
+
red.forEach(function (x) {
|
|
2213
|
+
var m = x[0], r = x[1];
|
|
2214
|
+
if (x[2]) box(m, r, under);
|
|
2215
|
+
else if (!keep) box(m, { left: r.left + sx, top: r.top + sy, width: r.width, height: r.height }, underPg);
|
|
2216
|
+
});
|
|
2217
|
+
if (fr) {
|
|
2218
|
+
var hr = fr[0], hp = fr[1];
|
|
2219
|
+
if (hp || (page && !keep)) {
|
|
2220
|
+
var hx = hp ? hr.left : hr.left + sx, hy = hp ? hr.top : hr.top + sy, hl = hp ? under : underPg;
|
|
2221
|
+
el("rect", { x: hx - 6, y: hy - 6, width: hr.width + 12, height: hr.height + 12, fill: "none", stroke: "#fff", "stroke-width": 8, rx: 6 }, hl);
|
|
2222
|
+
el("rect", { x: hx - 6, y: hy - 6, width: hr.width + 12, height: hr.height + 12, fill: "none", stroke: "#d0103a", "stroke-width": 4, rx: 6 }, hl);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
var hid = 0, placedPg = [], placedSc = [], pts = [], dotsPg = [], dotsSc = [];
|
|
2226
|
+
var big = stops.length > PAGE;
|
|
2227
|
+
group.style.display = big ? "" : "none";
|
|
2228
|
+
pager.style.display = paged() ? "" : "none";
|
|
2229
|
+
chunkBox.style.marginTop = paged() ? "" : "0";
|
|
2230
|
+
if (paged()) {
|
|
2231
|
+
pageText.textContent = "Stops " + (lo + 1) + " to " + hi + " of " + stops.length;
|
|
2232
|
+
prevBtn.disabled = win === 0;
|
|
2233
|
+
nextBtn.disabled = win === last;
|
|
2234
|
+
}
|
|
2235
|
+
stops.forEach(function (s, i) {
|
|
2236
|
+
if (i < lo || i >= hi) return;
|
|
2237
|
+
var r = at[i - lo][0];
|
|
2238
|
+
var tiny = at[i - lo][1];
|
|
2239
|
+
var onScreen = at[i - lo][2];
|
|
2240
|
+
var cx = tiny ? 13 + hid++ * 30 : onScreen ? Math.max(r.left - 8, 13) : Math.max(r.left + sx - 8, 13);
|
|
2241
|
+
var cy = tiny ? 13 : onScreen ? Math.max(r.top - 8, 13) : Math.max(r.top + sy - 8, 13);
|
|
2242
|
+
var placed = onScreen ? placedSc : placedPg;
|
|
2243
|
+
for (var j = placed.length - 1, tries = 0; j >= 0 && tries < 40; j--) {
|
|
2244
|
+
if (Math.abs(placed[j][0] - cx) < 26 && Math.abs(placed[j][1] - cy) < 26) {
|
|
2245
|
+
cx = placed[j][0] + 28;
|
|
2246
|
+
j = placed.length;
|
|
2247
|
+
tries++;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
placed.push([cx, cy]);
|
|
2251
|
+
pts.push([cx, cy, onScreen]);
|
|
2252
|
+
(onScreen ? dotsSc : dotsPg).push([cx, cy, i + 1, tiny]);
|
|
2253
|
+
});
|
|
2254
|
+
if (lines.checked && !stub.checked) shortLines(pts, sx, sy);
|
|
2255
|
+
var run = [], runPg = null;
|
|
2256
|
+
function flush() {
|
|
2257
|
+
if (runPg === null) return;
|
|
2258
|
+
if (runPg) { if (page) trailLine(run, svgPg); }
|
|
2259
|
+
else trailLine(run, svg);
|
|
2260
|
+
run = [];
|
|
2261
|
+
runPg = null;
|
|
2262
|
+
}
|
|
2263
|
+
for (var k = lines.checked && stub.checked ? 1 : pts.length; k < pts.length; k++) {
|
|
2264
|
+
var a = pts[k - 1], b = pts[k], both = !a[2] && !b[2];
|
|
2265
|
+
if (runPg !== both) {
|
|
2266
|
+
flush();
|
|
2267
|
+
runPg = both;
|
|
2268
|
+
run.push(both || a[2] ? [a[0], a[1]] : [a[0] - sx, a[1] - sy]);
|
|
2269
|
+
}
|
|
2270
|
+
run.push(both || b[2] ? [b[0], b[1]] : [b[0] - sx, b[1] - sy]);
|
|
2271
|
+
}
|
|
2272
|
+
flush();
|
|
2273
|
+
if (page) dotsIn(dotsPg, dotPg);
|
|
2274
|
+
dotsIn(dotsSc, dot);
|
|
2275
|
+
}
|
|
2276
|
+
function queue(screenOnly) {
|
|
2277
|
+
if (screenOnly !== true) onlyScreen = false;
|
|
2278
|
+
if (!queued) { queued = true; requestAnimationFrame(draw); }
|
|
2279
|
+
}
|
|
2280
|
+
var timer = 0, idle = 0, nextScan = 0, settling = false;
|
|
2281
|
+
function same(a, b) {
|
|
2282
|
+
if (a.length !== b.length) return false;
|
|
2283
|
+
for (var i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
2284
|
+
return true;
|
|
2285
|
+
}
|
|
2286
|
+
function rescan() {
|
|
2287
|
+
if (timer) clearTimeout(timer);
|
|
2288
|
+
if (idle && window.cancelIdleCallback) cancelIdleCallback(idle);
|
|
2289
|
+
timer = 0;
|
|
2290
|
+
idle = 0;
|
|
2291
|
+
if (closed) return;
|
|
2292
|
+
if (settling) return later();
|
|
2293
|
+
var t0 = performance.now();
|
|
2294
|
+
place();
|
|
2295
|
+
pinned = new WeakMap();
|
|
2296
|
+
scan();
|
|
2297
|
+
if (!same(drawn, sig())) {
|
|
2298
|
+
fill();
|
|
2299
|
+
scan();
|
|
2300
|
+
renderJumps();
|
|
2301
|
+
review();
|
|
2302
|
+
}
|
|
2303
|
+
focus();
|
|
2304
|
+
var t1 = performance.now();
|
|
2305
|
+
nextScan = t1 + Math.max(500, 4 * (t1 - t0));
|
|
2306
|
+
}
|
|
2307
|
+
var due = 0;
|
|
2308
|
+
function later(min) {
|
|
2309
|
+
if (idle || closed) return;
|
|
2310
|
+
var wait = Math.max(min || 500, nextScan - performance.now());
|
|
2311
|
+
if (timer) {
|
|
2312
|
+
if (performance.now() + wait >= due) return;
|
|
2313
|
+
clearTimeout(timer);
|
|
2314
|
+
}
|
|
2315
|
+
due = performance.now() + wait;
|
|
2316
|
+
timer = setTimeout(function () {
|
|
2317
|
+
timer = 0;
|
|
2318
|
+
if (window.requestIdleCallback) idle = requestIdleCallback(rescan, { timeout: 1000 });
|
|
2319
|
+
else rescan();
|
|
2320
|
+
}, wait);
|
|
2321
|
+
}
|
|
2322
|
+
var LOUD = /^(tabindex|disabled|inert|href|role|open|hidden)$/;
|
|
2323
|
+
function matters(m) {
|
|
2324
|
+
var t = m.target;
|
|
2325
|
+
if (t === host || host.contains(t)) return false;
|
|
2326
|
+
if (m.type === "childList") {
|
|
2327
|
+
var l = [].concat([].slice.call(m.addedNodes), [].slice.call(m.removedNodes));
|
|
2328
|
+
for (var i = 0; i < l.length; i++) if (l[i].nodeType === 1) return true;
|
|
2329
|
+
return false;
|
|
2330
|
+
}
|
|
2331
|
+
if (LOUD.test(m.attributeName || "") || t.nodeType !== 1) return true;
|
|
2332
|
+
if (stopSet.has(t) || upSet.has(t) || t.matches(FOCUSABLE) || t.querySelector(FOCUSABLE)) return true;
|
|
2333
|
+
return missed.concat(hovers, forced).some(function (x) { return t === x || t.contains(x); });
|
|
2334
|
+
}
|
|
2335
|
+
function onMoved(e) { if (host.style.position === "fixed") place(); queue((stub.checked || !lines.checked) && !!e && e.type === "scroll" && (e.target === document || e.target === document.documentElement)); later(); }
|
|
2336
|
+
var watch = new MutationObserver(function (list) {
|
|
2337
|
+
place();
|
|
2338
|
+
if (openPop && gone(openPop)) popClosed();
|
|
2339
|
+
for (var i = 0; i < list.length; i++) if (matters(list[i])) return later();
|
|
2340
|
+
later(3000);
|
|
2341
|
+
});
|
|
2342
|
+
function focus() {
|
|
2343
|
+
var a = deep();
|
|
2344
|
+
track(a);
|
|
2345
|
+
if (a && a !== document.body && a !== document.documentElement) {
|
|
2346
|
+
lost = false;
|
|
2347
|
+
if (a !== host && a.getRootNode() !== root) spotEl = a;
|
|
2348
|
+
} else spotEl = null;
|
|
2349
|
+
current = stops.indexOf(a);
|
|
2350
|
+
if (current !== seen) {
|
|
2351
|
+
seen = current;
|
|
2352
|
+
if (current >= 0) win = Math.floor(current / PAGE);
|
|
2353
|
+
}
|
|
2354
|
+
queue();
|
|
2355
|
+
}
|
|
2356
|
+
function lose(e) {
|
|
2357
|
+
var t = e && !e.relatedTarget && e.composedPath ? e.composedPath()[0] : null, p = t && t.nodeType === 1 ? popupOf(t) : null;
|
|
2358
|
+
if (p && p === openPop) requestAnimationFrame(function () { if (!closed && openPop === p && gone(p)) popClosed(); });
|
|
2359
|
+
setTimeout(function () {
|
|
2360
|
+
var a = document.activeElement;
|
|
2361
|
+
if (a && a !== document.body && a !== document.documentElement) return;
|
|
2362
|
+
lost = true;
|
|
2363
|
+
focus();
|
|
2364
|
+
}, 0);
|
|
2365
|
+
}
|
|
2366
|
+
var walking = false, walkDelay = 400, walkT = 0, walked = new Set(), walkAt = null, walkEnd = null;
|
|
2367
|
+
function walkedN() { return stops.filter(function (s) { return walked.has(s); }).length; }
|
|
2368
|
+
function playState() {
|
|
2369
|
+
var at = walkAt && stops.indexOf(walkAt) >= 0 ? " at stop " + (stops.indexOf(walkAt) + 1) + " \"" + label(walkAt) + "\"" : "";
|
|
2370
|
+
var n = "walked " + walkedN() + " of " + pl(stops.length, "stop", "stops");
|
|
2371
|
+
if (walking) return "still walking" + at + ", " + n;
|
|
2372
|
+
return walkEnd === "done" ? "finished, " + n : "paused" + at + ", " + n;
|
|
2373
|
+
}
|
|
2374
|
+
function playLook() {
|
|
2375
|
+
while (playIcon.firstChild) playIcon.removeChild(playIcon.firstChild);
|
|
2376
|
+
icon(playIcon, 12, walking ? "M5 3v10M11 3v10" : "M4 2.5l9 5.5-9 5.5z", 2.4);
|
|
2377
|
+
playWord.textContent = walking ? "Pause" : "Play";
|
|
2378
|
+
play.setAttribute("aria-pressed", walking ? "true" : "false");
|
|
2379
|
+
if (walked.size) playText.textContent = "Walked " + walkedN() + " of " + stops.length + " stops";
|
|
2380
|
+
}
|
|
2381
|
+
function walkedText() { return " after " + walkedN() + " of " + pl(stops.length, "stop", "stops") + "."; }
|
|
2382
|
+
function stopWalk(why, fin) {
|
|
2383
|
+
if (!walking) return;
|
|
2384
|
+
walking = false;
|
|
2385
|
+
walkEnd = fin ? "done" : "paused";
|
|
2386
|
+
settling = false;
|
|
2387
|
+
if (walkT) clearTimeout(walkT);
|
|
2388
|
+
walkT = 0;
|
|
2389
|
+
playLook();
|
|
2390
|
+
if (why) log("INFO", "Play it", [why]);
|
|
2391
|
+
sumDraw();
|
|
2392
|
+
if (fin) announce("Walked " + walkedN() + " of " + pl(stops.length, "stop", "stops") + ". " + pl(logCounts().bad, "problem", "problems") + ".");
|
|
2393
|
+
else if (why) announce("Play paused" + (walkAt && stops.indexOf(walkAt) >= 0 ? " at stop " + (stops.indexOf(walkAt) + 1) : "") + ". Walked " + walkedN() + " of " + pl(stops.length, "stop", "stops") + ".");
|
|
2394
|
+
var done = walkDone;
|
|
2395
|
+
walkDone = [];
|
|
2396
|
+
done.forEach(function (f) { f(aiText()); });
|
|
2397
|
+
}
|
|
2398
|
+
function step(s) {
|
|
2399
|
+
walkT = 0;
|
|
2400
|
+
if (!walking || closed) return;
|
|
2401
|
+
if (!s || stops.indexOf(s) < 0) s = stops.filter(function (x) { return !walked.has(x); })[0];
|
|
2402
|
+
if (!s) {
|
|
2403
|
+
stopWalk("Finished: walked " + walkedN() + " of " + pl(stops.length, "stop", "stops") + ".", true);
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
endPress();
|
|
2407
|
+
s.focus({ focusVisible: true });
|
|
2408
|
+
focus();
|
|
2409
|
+
walked.add(s);
|
|
2410
|
+
walkAt = s;
|
|
2411
|
+
playLook();
|
|
2412
|
+
var at = where(s), still = 0, tries = 0;
|
|
2413
|
+
settling = true;
|
|
2414
|
+
function wait() {
|
|
2415
|
+
if (!walking || closed) return void (settling = false);
|
|
2416
|
+
var now = where(s);
|
|
2417
|
+
if (now !== at) {
|
|
2418
|
+
at = now;
|
|
2419
|
+
still = 0;
|
|
2420
|
+
} else still++;
|
|
2421
|
+
if (++tries < 90 && (still < 2 || tries < 6)) return requestAnimationFrame(wait);
|
|
2422
|
+
settling = false;
|
|
2423
|
+
hoverTry(s);
|
|
2424
|
+
check(s, function () {
|
|
2425
|
+
if (walking && !closed) walkT = setTimeout(function () { step(); }, walkDelay);
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
requestAnimationFrame(wait);
|
|
2429
|
+
}
|
|
2430
|
+
var walkDone = [];
|
|
2431
|
+
function untested() {
|
|
2432
|
+
var judged = {};
|
|
2433
|
+
logs.forEach(function (e) { if ((e.k === "OK" || e.k === "PROBLEM") && e.f === "Lost focus") judged[e.f] = 1; });
|
|
2434
|
+
if (judgedDir[1] && judgedDir[-1]) judged["Out of order"] = judged["Keyboard trap"] = 1;
|
|
2435
|
+
openProbs().forEach(function (e) { judged[e.f] = 1; });
|
|
2436
|
+
return ["Out of order", "Keyboard trap", "Lost focus"].filter(function (f) { return !judged[f]; });
|
|
2437
|
+
}
|
|
2438
|
+
function sumDraw() {
|
|
2439
|
+
sumLine.hidden = walking || walkEnd !== "done";
|
|
2440
|
+
if (sumLine.hidden) return;
|
|
2441
|
+
var per = {}, probs = openProbs(), left = untested();
|
|
2442
|
+
probs.forEach(function (e) { per[e.f] = (per[e.f] || 0) + 1; });
|
|
2443
|
+
var red = CHECKS.filter(function (f) { return per[f]; }), ok = CHECKS.filter(function (f) { return !per[f] && left.indexOf(f) < 0; });
|
|
2444
|
+
var tabLeft = left.indexOf("Out of order") >= 0 || left.indexOf("Keyboard trap") >= 0, popLeft = left.indexOf("Lost focus") >= 0;
|
|
2445
|
+
while (sumLine.firstChild) sumLine.removeChild(sumLine.firstChild);
|
|
2446
|
+
var b = document.createElement("b");
|
|
2447
|
+
b.textContent = pl(CHECKS.length, "check", "checks") + ": " + ok.length + " passed, " + red.length + (red.length === 1 ? " found a problem, " : " found problems, ") + left.length + " not tested.";
|
|
2448
|
+
sumLine.appendChild(b);
|
|
2449
|
+
function part(head, list, cls, count) {
|
|
2450
|
+
if (!list.length) return;
|
|
2451
|
+
sumLine.appendChild(document.createTextNode(" " + head + ": "));
|
|
2452
|
+
var sp = document.createElement("span");
|
|
2453
|
+
sp.className = cls;
|
|
2454
|
+
sp.textContent = list.map(function (f) { return f + (count ? " " + per[f] : ""); }).join(", ");
|
|
2455
|
+
sumLine.appendChild(sp);
|
|
2456
|
+
sumLine.appendChild(document.createTextNode("."));
|
|
2457
|
+
}
|
|
2458
|
+
part("Passed", ok, "g");
|
|
2459
|
+
part(red.length === 1 ? "Problem" : "Problems", red, "e", true);
|
|
2460
|
+
part("Not tested (" + (tabLeft && popLeft ? "press Tab and Shift+Tab, open and close a popup" : tabLeft ? "press Tab and Shift+Tab" : "open and close a popup") + ")", left, "q");
|
|
2461
|
+
}
|
|
2462
|
+
function startWalk() {
|
|
2463
|
+
walking = true;
|
|
2464
|
+
sumDraw();
|
|
2465
|
+
if (walkedN() >= stops.length) walked = new Set();
|
|
2466
|
+
playLook();
|
|
2467
|
+
var first = current >= 0 && current < stops.length - 1 && walked.size ? current + 1 : 0;
|
|
2468
|
+
if (stops[first]) {
|
|
2469
|
+
log("INFO", "Play it", [first ? "Went on from " : "Started at ", ref(stops[first]), "."]);
|
|
2470
|
+
announce((first ? "Play went on from stop " : "Play started at stop ") + (first + 1) + ".");
|
|
2471
|
+
}
|
|
2472
|
+
step(stops[first]);
|
|
2473
|
+
}
|
|
2474
|
+
play.addEventListener("click", function () {
|
|
2475
|
+
if (walking) return stopWalk("Paused with the Pause button" + walkedText());
|
|
2476
|
+
walkDelay = 400;
|
|
2477
|
+
startWalk();
|
|
2478
|
+
});
|
|
2479
|
+
function interrupt(e) {
|
|
2480
|
+
if (!walking || (e.composedPath && e.composedPath().indexOf(host) >= 0)) return;
|
|
2481
|
+
stopWalk("Paused by a click on the page" + walkedText());
|
|
2482
|
+
}
|
|
2483
|
+
playLook();
|
|
2484
|
+
var SAFARI = MAC && /^Safari /.test(browser()), FIREFOX = MAC && /^Firefox /.test(browser());
|
|
2485
|
+
var settleT = 0, macNote = false, beforeEl = null, wantEl = null, MAC_NOTE = SAFARI ? "Safari skips links and buttons on Tab until you turn it on: Settings, Advanced, Press Tab to highlight each item." : "Firefox skips links on Tab until you turn it on: System Settings, Keyboard, Keyboard navigation.";
|
|
2486
|
+
var LINKS = "a[href],area[href]", SKIPS = SAFARI ? ["a[href]", "area[href]", "button", "input[type=button]", "input[type=submit]", "input[type=reset]", "input[type=image]", "input[type=checkbox]", "input[type=radio]", "input[type=range]", "input[type=file]", "input[type=color]"].map(function (q) { return q + ":not([tabindex])"; }).join(",") : LINKS;
|
|
2487
|
+
function linkSkip(want, cur, dir) {
|
|
2488
|
+
if (!SAFARI && !FIREFOX) return null;
|
|
2489
|
+
var n = stops.length, k = 0, links = 0;
|
|
2490
|
+
for (var i = want; i !== cur && k < n; i = (i + dir + n) % n, k++) {
|
|
2491
|
+
if (!stops[i].matches(SKIPS)) return null;
|
|
2492
|
+
if (stops[i].matches(LINKS)) links++;
|
|
2493
|
+
}
|
|
2494
|
+
return k && k < n ? [links, k - links] : null;
|
|
2495
|
+
}
|
|
2496
|
+
function skipText(c) {
|
|
2497
|
+
var l = c[0] ? pl(c[0], "link", "links") : "", b = c[1] ? pl(c[1], "button", "buttons") : "";
|
|
2498
|
+
return l && b ? l + " and " + b : l || b;
|
|
2499
|
+
}
|
|
2500
|
+
function after(el, dir) {
|
|
2501
|
+
var ord = new Map(), n = stops.length, pick = -1;
|
|
2502
|
+
walk(document, []).forEach(function (e, i) { ord.set(e, i); });
|
|
2503
|
+
var at = ord.get(el);
|
|
2504
|
+
if (at === undefined) return dir > 0 ? 0 : n - 1;
|
|
2505
|
+
for (var i = 0; i < n; i++) {
|
|
2506
|
+
var k = ord.get(stops[i]);
|
|
2507
|
+
if (stops[i].tabIndex > 0 || k === undefined) continue;
|
|
2508
|
+
if (dir > 0 && k > at) return i;
|
|
2509
|
+
if (dir < 0 && k < at) pick = i;
|
|
2510
|
+
}
|
|
2511
|
+
return dir > 0 ? 0 : pick >= 0 ? pick : forced.length ? forced.length - 1 : n - 1;
|
|
2512
|
+
}
|
|
2513
|
+
var stays = new WeakMap(), leaves = new WeakMap();
|
|
2514
|
+
function tellsHow(e) {
|
|
2515
|
+
if (!(e.tagName === "TEXTAREA" || e.isContentEditable || /^(application|textbox)$/.test(e.getAttribute("role") || ""))) return false;
|
|
2516
|
+
var r = e.getRootNode(), t = (e.getAttribute("aria-description") || "") + " " + (e.getAttribute("aria-keyshortcuts") || "") + " " + (e.getAttribute("title") || "");
|
|
2517
|
+
(e.getAttribute("aria-describedby") || "").split(/\s+/).forEach(function (id) { var x = id && r.getElementById ? r.getElementById(id) : null; if (x) t += " " + x.textContent; });
|
|
2518
|
+
return /\b(escape|esc)\b/i.test(t);
|
|
2519
|
+
}
|
|
2520
|
+
function multi(e) { return /^(IFRAME|OBJECT|EMBED|AUDIO|VIDEO)$/.test(e.tagName) || !!e.shadowRoot || (e.tagName === "INPUT" && /^(date|datetime-local|month|time|week)$/.test(e.type)); }
|
|
2521
|
+
function endPress() {
|
|
2522
|
+
if (settleT) {
|
|
2523
|
+
clearTimeout(settleT);
|
|
2524
|
+
settle();
|
|
2525
|
+
}
|
|
2526
|
+
pressed = 0;
|
|
2527
|
+
}
|
|
2528
|
+
function settle() {
|
|
2529
|
+
settleT = 0;
|
|
2530
|
+
focus();
|
|
2531
|
+
if (pressed && current >= 0) {
|
|
2532
|
+
check(stops[current]);
|
|
2533
|
+
hoverTry(stops[current]);
|
|
2534
|
+
}
|
|
2535
|
+
if (!pressed || current < 0 || before === -2) {
|
|
2536
|
+
if (pressed && before === -2) log("SKIPPED", "Out of order", ["Focus was on the page body, so this Tab press is not judged."]);
|
|
2537
|
+
else if (pressed) {
|
|
2538
|
+
var o = deep();
|
|
2539
|
+
if (o && o !== document.body && o !== document.documentElement && !within(host, o)) log("SKIPPED", "Out of order", ["Tab landed on ", ref(o), ", which is not in the list of stops. Not judged."]);
|
|
2540
|
+
else if (!o || !within(host, o)) log("SKIPPED", "Out of order", ["Focus left the page, or went to the browser. Not judged."]);
|
|
2541
|
+
}
|
|
2542
|
+
pressed = 0;
|
|
2543
|
+
return;
|
|
2544
|
+
}
|
|
2545
|
+
var w0 = before >= 0 ? (before + pressed + stops.length) % stops.length : -1;
|
|
2546
|
+
if (w0 >= 0 && w0 !== current && !tabbable(stops[w0])) {
|
|
2547
|
+
var fromEl = stops[before], toEl = stops[current];
|
|
2548
|
+
rescan();
|
|
2549
|
+
current = stops.indexOf(toEl);
|
|
2550
|
+
before = stops.indexOf(fromEl);
|
|
2551
|
+
if (before < 0) beforeEl = fromEl;
|
|
2552
|
+
if (current < 0) {
|
|
2553
|
+
log("SKIPPED", "Out of order", ["Tab landed on ", ref(toEl), ", which is not in the list of stops. Not judged."]);
|
|
2554
|
+
pressed = 0;
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
var n = stops.length, src = before >= 0 ? null : beforeEl, first = before < 0 && !src;
|
|
2559
|
+
var want = before >= 0 ? (before + pressed + n) % n : src ? after(src, pressed) : pressed > 0 ? 0 : n - 1;
|
|
2560
|
+
if (before >= 0 && wantEl && stops.indexOf(wantEl) >= 0) want = stops.indexOf(wantEl);
|
|
2561
|
+
var landed = popupOf(stops[current]), left = before >= 0 ? popupOf(stops[before]) : src ? popupOf(src) : null;
|
|
2562
|
+
if (first && pressed > 0 && !landed && !popMissed) {
|
|
2563
|
+
for (var k = 0; k < n && !popMissed; k++) {
|
|
2564
|
+
var pop = popupOf(stops[k]);
|
|
2565
|
+
if (pop && shown(pop) && blocking(pop)) popMissed = pop;
|
|
2566
|
+
}
|
|
2567
|
+
if (popMissed) {
|
|
2568
|
+
renderJumps();
|
|
2569
|
+
announce("A popup blocks the page, but the first Tab went somewhere else.");
|
|
2570
|
+
log("PROBLEM", "Out of order", [popName(popMissed), " blocks the page, but the first Tab went to ", ref(stops[current]), "."], aiOf(W_ORDER, "A popup that blocks the page gets keyboard focus first, so the first Tab lands inside it.", "When the popup opens, move focus into it: call .focus() on its first control, or on the popup itself with tabindex=\"-1\". A <dialog> opened with showModal() does this by itself.", [["Popup", popMissed], ["First Tab went to", stops[current]]]));
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
var start = before >= 0 ? [ref(stops[before])] : src ? [ref(src)] : ["Start"], back = pressed < 0 ? " (Shift+Tab)" : "";
|
|
2574
|
+
if (current === before && current !== want && !landed && !left) {
|
|
2575
|
+
var s = stops[current];
|
|
2576
|
+
var d = pressed > 0 ? 1 : -1, st = stays.get(s) || stays.set(s, {}).get(s), key1 = d > 0 ? "Tab" : "Shift+Tab", key2 = d > 0 ? "Shift+Tab" : "Tab";
|
|
2577
|
+
if (multi(s)) log("SKIPPED", "Out of order", start.concat([" \u2192 ", ref(s), back + ": Tab moved inside it, it has parts of its own (like a date field, a video or a frame). Not judged."]));
|
|
2578
|
+
else if (tellsHow(s)) {
|
|
2579
|
+
if (!st.how) log("SKIPPED", "Keyboard trap", [ref(s), " keeps Tab, and says how to leave."]);
|
|
2580
|
+
st.how = 1;
|
|
2581
|
+
} else if (!st[d] && (leaves.get(s) || {})[-d]) {
|
|
2582
|
+
st[d] = 1;
|
|
2583
|
+
log("OK", "Keyboard trap", [key1 + " stays on ", ref(s), ", but " + key2 + " leaves it, so it is not a trap."]);
|
|
2584
|
+
} else if (!st[d] && !st[-d]) {
|
|
2585
|
+
st[d] = 1;
|
|
2586
|
+
log("SKIPPED", "Keyboard trap", [key1 + " stays on ", ref(s), ". Press " + key2 + ": if focus can't leave that way either, it is a keyboard trap."]);
|
|
2587
|
+
} else if (!st[d] && trapped.indexOf(s) < 0) {
|
|
2588
|
+
st[d] = 1;
|
|
2589
|
+
trapped.push(s);
|
|
2590
|
+
renderJumps();
|
|
2591
|
+
announce("Keyboard trap: Tab and Shift+Tab both stay on stop " + (current + 1) + ".");
|
|
2592
|
+
log("PROBLEM", "Keyboard trap", ["Tab and Shift+Tab both stay on ", ref(s), ": the keyboard can't move focus away."], aiOf(W_TRAP, "Tab or Shift+Tab moves focus away from the element, so a keyboard user can leave it.", "Find the keydown listener on the element or its parents that calls preventDefault() on Tab, or that calls .focus() on the same element again, and let Tab through. If the element needs Tab (a code editor), let Escape move focus out and say so next to it.", [["Element", s], ["Expected next", stops[(current + 1) % n]]]));
|
|
2593
|
+
}
|
|
2594
|
+
pressed = 0;
|
|
2595
|
+
return;
|
|
2596
|
+
}
|
|
2597
|
+
if (before >= 0 && current !== before) {
|
|
2598
|
+
var lv = leaves.get(stops[before]) || leaves.set(stops[before], {}).get(stops[before]), sd = pressed > 0 ? 1 : -1, so = stays.get(stops[before]);
|
|
2599
|
+
if (!lv[sd] && so && so[-sd] && !so[sd] && trapped.indexOf(stops[before]) < 0) log("OK", "Keyboard trap", [(sd > 0 ? "Tab" : "Shift+Tab") + " leaves ", ref(stops[before]), ", so it is not a trap."]);
|
|
2600
|
+
lv[sd] = 1;
|
|
2601
|
+
}
|
|
2602
|
+
var skipped = current !== want && !landed && !left ? linkSkip(want, current, pressed > 0 ? 1 : -1) : null;
|
|
2603
|
+
if (first && pressed > 0 && landed) log("OK", "Out of order", ["First Tab went into the popup ", popName(landed), "."]);
|
|
2604
|
+
else if (skipped) {
|
|
2605
|
+
if (!macNote) {
|
|
2606
|
+
macNote = true;
|
|
2607
|
+
renderJumps();
|
|
2608
|
+
log("INFO", "Out of order", [MAC_NOTE]);
|
|
2609
|
+
}
|
|
2610
|
+
log("SKIPPED", "Out of order", start.concat([" → ", ref(stops[current]), back + ": your browser skipped " + skipText(skipped) + ". Not judged."]));
|
|
2611
|
+
} else if (current !== want && !landed && !left && !(popMissed && first)) {
|
|
2612
|
+
var from = before >= 0 ? stops[before] : src, to = stops[current], fromText = before >= 0 ? "stop " + (before + 1) : src ? "\"" + label(src) + "\" " + desc(src) : "the start of the page";
|
|
2613
|
+
announce("Tab jumped out of order, from " + (before >= 0 ? "stop " + (before + 1) : src ? label(src) : "the start") + " to stop " + (current + 1) + ".");
|
|
2614
|
+
if (!jumps.some(function (j) { return j[0] === from && j[1] === to; })) {
|
|
2615
|
+
jumps.push([from, to]);
|
|
2616
|
+
renderJumps();
|
|
2617
|
+
}
|
|
2618
|
+
log("PROBLEM", "Out of order", start.concat([" → ", ref(to), back + ", expected ", ref(stops[want]), to.tabIndex > 0 ? ". It has tabindex=\"" + to.tabIndex + "\"." : "."]), aiOf(W_ORDER, "Tab" + (pressed < 0 ? " with Shift" : "") + " moves from " + fromText + " to stop " + (want + 1) + ", the next element in the Tab order.", to.tabIndex > 0 ? "Remove tabindex=\"" + to.tabIndex + "\" from the element Tab jumped to, or set it to 0. A positive tabindex pulls an element ahead of the page order." : "Tab follows the order of the HTML, so a jump comes from a script. Look for code that calls .focus() on focus, blur or keydown near the element Tab left from, and for content added or moved while Tab was pressed. If the element Tab jumped to sits elsewhere in the HTML on purpose, move it next to the one before it.", [["Tab left from", from], ["Tab jumped to", to], ["Expected next", stops[want]]]));
|
|
2619
|
+
} else if (current !== want) log("SKIPPED", "Out of order", start.concat([" → ", ref(stops[current]), back + (landed || left ? ": into or inside a popup, allowed." : ": the popup that blocks the page is listed already.")]));
|
|
2620
|
+
else log("OK", "Out of order", start.concat([" → ", ref(stops[current]), back + ", next in line."]));
|
|
2621
|
+
pressed = 0;
|
|
2622
|
+
}
|
|
2623
|
+
function inPanel() {
|
|
2624
|
+
var a = root.activeElement;
|
|
2625
|
+
return !!a && panel.contains(a);
|
|
2626
|
+
}
|
|
2627
|
+
function panelCtl() {
|
|
2628
|
+
return [].filter.call(panel.querySelectorAll("button,a,input"), function (e) { return !e.disabled && e.getClientRects().length > 0; });
|
|
2629
|
+
}
|
|
2630
|
+
function enter() {
|
|
2631
|
+
endPress();
|
|
2632
|
+
if (walking) stopWalk("Paused by " + KEYS + walkedText());
|
|
2633
|
+
var a = deep();
|
|
2634
|
+
pRet = a && a !== document.body && a !== document.documentElement && a !== host && a.getRootNode() !== root ? a : null;
|
|
2635
|
+
panelIn = true;
|
|
2636
|
+
skipPanel();
|
|
2637
|
+
play.focus({ focusVisible: true });
|
|
2638
|
+
}
|
|
2639
|
+
function back() {
|
|
2640
|
+
var r = pRet;
|
|
2641
|
+
panelIn = false;
|
|
2642
|
+
pRet = null;
|
|
2643
|
+
skipPanel();
|
|
2644
|
+
if (r && r.isConnected) r.focus({ focusVisible: true });
|
|
2645
|
+
else {
|
|
2646
|
+
var a = root.activeElement;
|
|
2647
|
+
if (a && a.blur) a.blur();
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
function key(e) {
|
|
2651
|
+
if (e.code === "KeyF" && e.ctrlKey && e.shiftKey && !e.altKey && !e.metaKey) {
|
|
2652
|
+
e.preventDefault();
|
|
2653
|
+
e.stopPropagation();
|
|
2654
|
+
if (inPanel()) back();
|
|
2655
|
+
else enter();
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
if (e.key !== "Tab" && settleT) endPress();
|
|
2659
|
+
lastKey = e.key;
|
|
2660
|
+
keyT = Date.now();
|
|
2661
|
+
keyOn = deep();
|
|
2662
|
+
if (walking && (e.key === " " || e.key === "Tab" || e.key === "Escape")) {
|
|
2663
|
+
if (e.key === " ") e.preventDefault();
|
|
2664
|
+
stopWalk("Paused by " + (e.key === " " ? "Space" : e.key) + walkedText());
|
|
2665
|
+
if (e.key !== "Tab") return;
|
|
2666
|
+
}
|
|
2667
|
+
if (panelIn && inPanel()) {
|
|
2668
|
+
if (e.key === "Escape") {
|
|
2669
|
+
e.preventDefault();
|
|
2670
|
+
return back();
|
|
2671
|
+
}
|
|
2672
|
+
if (e.key === "Tab" && skip.checked) {
|
|
2673
|
+
var l = panelCtl(), i = l.indexOf(root.activeElement), n = l.length;
|
|
2674
|
+
e.preventDefault();
|
|
2675
|
+
if (n) l[i < 0 ? 0 : (i + (e.shiftKey ? -1 : 1) + n) % n].focus({ focusVisible: true });
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
var fa = deep(), onBody = !fa || fa === document.body || fa === document.documentElement;
|
|
2680
|
+
if (e.key === "Escape" && !modal() && !(openPop && !gone(openPop)) && (onBody || inPanel())) close();
|
|
2681
|
+
if (e.key === "Tab") {
|
|
2682
|
+
endPress();
|
|
2683
|
+
fa = deep();
|
|
2684
|
+
pressed = e.shiftKey ? -1 : 1;
|
|
2685
|
+
before = current < 0 && lost ? -2 : current;
|
|
2686
|
+
beforeEl = current < 0 && !lost && fa && fa !== document.body && fa !== document.documentElement && !within(host, fa) ? fa : null;
|
|
2687
|
+
wantEl = null;
|
|
2688
|
+
for (var k = 1, n = stops.length; before >= 0 && k < n; k++) {
|
|
2689
|
+
var c = stops[(((before + pressed * k) % n) + n) % n];
|
|
2690
|
+
if (tabbable(c)) {
|
|
2691
|
+
wantEl = c;
|
|
2692
|
+
break;
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
settleT = setTimeout(settle, 150);
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
function pick(e) {
|
|
2699
|
+
var g = e.target.closest && e.target.closest("g.o");
|
|
2700
|
+
if (!g) return;
|
|
2701
|
+
e.preventDefault();
|
|
2702
|
+
e.stopPropagation();
|
|
2703
|
+
if (e.type !== "click") return;
|
|
2704
|
+
var s = stops[+g.getAttribute("data-i")];
|
|
2705
|
+
if (!s) return;
|
|
2706
|
+
endPress();
|
|
2707
|
+
s.focus({ preventScroll: true, focusVisible: true });
|
|
2708
|
+
focus();
|
|
2709
|
+
}
|
|
2710
|
+
function close() {
|
|
2711
|
+
closed = true;
|
|
2712
|
+
stopWalk();
|
|
2713
|
+
removeEventListener("pointerdown", interrupt, true);
|
|
2714
|
+
removeEventListener("pointerdown", tap, true);
|
|
2715
|
+
removeEventListener("scroll", onMoved, true);
|
|
2716
|
+
removeEventListener("resize", onMoved);
|
|
2717
|
+
removeEventListener("resize", keepIn);
|
|
2718
|
+
if (fit) fit.disconnect();
|
|
2719
|
+
watch.disconnect();
|
|
2720
|
+
if (timer) clearTimeout(timer);
|
|
2721
|
+
if (idle && window.cancelIdleCallback) cancelIdleCallback(idle);
|
|
2722
|
+
if (sayT) clearTimeout(sayT);
|
|
2723
|
+
if (settleT) clearTimeout(settleT);
|
|
2724
|
+
removeEventListener("keydown", key, true);
|
|
2725
|
+
removeEventListener("focusin", focus, true);
|
|
2726
|
+
removeEventListener("focusout", lose, true);
|
|
2727
|
+
if (tabPoll) clearInterval(tabPoll);
|
|
2728
|
+
if (logTab && !logTab.closed && tabNote) tabNote.hidden = false;
|
|
2729
|
+
if (window.__tabTrail === api) delete window.__tabTrail;
|
|
2730
|
+
if (ownName) window.name = "";
|
|
2731
|
+
host.remove();
|
|
2732
|
+
}
|
|
2733
|
+
var grab = null;
|
|
2734
|
+
panel.addEventListener("pointerdown", function (e) {
|
|
2735
|
+
if (e.button !== 0 || e.target.closest("button,a,ul,label")) return;
|
|
2736
|
+
var r = panel.getBoundingClientRect();
|
|
2737
|
+
grab = [e.clientX - r.left, e.clientY - r.top];
|
|
2738
|
+
panel.setPointerCapture(e.pointerId);
|
|
2739
|
+
panel.classList.add("g");
|
|
2740
|
+
});
|
|
2741
|
+
panel.addEventListener("pointermove", function (e) {
|
|
2742
|
+
if (!grab) return;
|
|
2743
|
+
var x = Math.min(Math.max(e.clientX - grab[0], 0), innerWidth - panel.offsetWidth);
|
|
2744
|
+
var y = Math.min(Math.max(e.clientY - grab[1], 0), innerHeight - panel.offsetHeight);
|
|
2745
|
+
panel.style.left = x + "px";
|
|
2746
|
+
panel.style.top = y + "px";
|
|
2747
|
+
panel.style.right = "auto";
|
|
2748
|
+
panel.style.bottom = "auto";
|
|
2749
|
+
});
|
|
2750
|
+
function drop() { grab = null; panel.classList.remove("g"); }
|
|
2751
|
+
function keepIn() {
|
|
2752
|
+
if (closed) return;
|
|
2753
|
+
var r = panel.getBoundingClientRect(), m = 8;
|
|
2754
|
+
if (!r.height || (r.top >= m && r.bottom <= innerHeight - m && r.left >= m && r.right <= innerWidth - m)) return;
|
|
2755
|
+
panel.style.top = Math.min(Math.max(r.top, m), Math.max(m, innerHeight - m - r.height)) + "px";
|
|
2756
|
+
panel.style.left = Math.min(Math.max(r.left, m), Math.max(m, innerWidth - m - r.width)) + "px";
|
|
2757
|
+
panel.style.right = "auto";
|
|
2758
|
+
panel.style.bottom = "auto";
|
|
2759
|
+
}
|
|
2760
|
+
var fit = window.ResizeObserver ? new ResizeObserver(keepIn) : null;
|
|
2761
|
+
if (fit) fit.observe(panel);
|
|
2762
|
+
addEventListener("resize", keepIn);
|
|
2763
|
+
panel.addEventListener("pointerup", drop);
|
|
2764
|
+
panel.addEventListener("pointercancel", drop);
|
|
2765
|
+
host.__close = close;
|
|
2766
|
+
function mainOf(e) {
|
|
2767
|
+
var first = null;
|
|
2768
|
+
for (var i = 0; i < e.p.length; i++) {
|
|
2769
|
+
var x = e.p[i];
|
|
2770
|
+
if (typeof x === "string" || !x.el) continue;
|
|
2771
|
+
if (i && typeof e.p[i - 1] === "string" && /\u2192 $/.test(e.p[i - 1])) return x;
|
|
2772
|
+
if (!first) first = x;
|
|
2773
|
+
}
|
|
2774
|
+
return first;
|
|
2775
|
+
}
|
|
2776
|
+
var api = {
|
|
2777
|
+
report: function () { return aiText(); },
|
|
2778
|
+
log: function () {
|
|
2779
|
+
return logs.map(function (e) {
|
|
2780
|
+
var m = mainOf(e);
|
|
2781
|
+
return { time: clock(e.t), result: e.k, check: e.f, wcag: wcagOf(e) || null, text: e.p.map(partText).join(""), fixed: !!e.fixed, selector: m ? sel(m.el) || null : null, stop: m && m.n ? m.n : null };
|
|
2782
|
+
});
|
|
2783
|
+
},
|
|
2784
|
+
play: function (o) {
|
|
2785
|
+
o = o || {};
|
|
2786
|
+
var skipOut = [].concat(o.ignore || []);
|
|
2787
|
+
for (var i = 0; i < skipOut.length; i++) {
|
|
2788
|
+
try { document.querySelector(skipOut[i]); } catch (x) { return Promise.reject(new Error("Tab trail: \"" + skipOut[i] + "\" in ignore is not a valid CSS selector.")); }
|
|
2789
|
+
}
|
|
2790
|
+
ignore = skipOut;
|
|
2791
|
+
walkDelay = typeof o.delay === "number" && o.delay >= 0 ? o.delay : 400;
|
|
2792
|
+
return new Promise(function (res) {
|
|
2793
|
+
walkDone.push(res);
|
|
2794
|
+
if (!walking) {
|
|
2795
|
+
walked = new Set();
|
|
2796
|
+
startWalk();
|
|
2797
|
+
}
|
|
2798
|
+
});
|
|
2799
|
+
},
|
|
2800
|
+
problems: function () { return problemsOf(openProbs()); },
|
|
2801
|
+
state: function () { return { walked: walkedN(), total: stops.length, done: !walking && walkEnd === "done" && stops.every(function (x) { return hidTested.has(x); }), untested: untested() }; },
|
|
2802
|
+
version: VERSION,
|
|
2803
|
+
close: function () { close(); }
|
|
2804
|
+
};
|
|
2805
|
+
window.__tabTrail = api;
|
|
2806
|
+
x.addEventListener("click", close);
|
|
2807
|
+
addEventListener("scroll", onMoved, { capture: true, passive: true });
|
|
2808
|
+
addEventListener("resize", onMoved);
|
|
2809
|
+
watch.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ["style", "class", "hidden", "tabindex", "disabled", "inert", "href", "role", "open"] });
|
|
2810
|
+
addEventListener("keydown", key, true);
|
|
2811
|
+
addEventListener("pointerdown", interrupt, true);
|
|
2812
|
+
addEventListener("pointerdown", tap, true);
|
|
2813
|
+
addEventListener("focusin", focus, true);
|
|
2814
|
+
addEventListener("focusout", lose, true);
|
|
2815
|
+
root.addEventListener("focusin", function () {
|
|
2816
|
+
if (root.activeElement === panel && panel.tabIndex < 0) return panel.blur();
|
|
2817
|
+
focus();
|
|
2818
|
+
});
|
|
2819
|
+
root.addEventListener("focusout", function () {
|
|
2820
|
+
setTimeout(function () {
|
|
2821
|
+
if (!panelIn || closed || inPanel()) return;
|
|
2822
|
+
var a = deep();
|
|
2823
|
+
if ((!a || a === document.body || a === document.documentElement) && Date.now() - tapT > 600) return play.focus({ focusVisible: true });
|
|
2824
|
+
panelIn = false;
|
|
2825
|
+
pRet = null;
|
|
2826
|
+
skipPanel();
|
|
2827
|
+
}, 0);
|
|
2828
|
+
});
|
|
2829
|
+
["pointerdown", "mousedown", "pointerup", "mouseup", "click"].forEach(function (t) {
|
|
2830
|
+
dot.addEventListener(t, pick);
|
|
2831
|
+
dotPg.addEventListener(t, pick);
|
|
2832
|
+
});
|
|
2833
|
+
review();
|
|
2834
|
+
focus();
|
|
2835
|
+
draw();
|
|
2836
|
+
})();
|