@ngbracket/a11y-devtools 0.19.0 → 0.20.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 +39 -0
- package/README.md +4 -0
- package/bin/ngbr-a11y-report.mjs +13 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inpage.global.js +218 -1
- package/dist/inpage.js +4 -0
- package/dist/keyboard/focus-walk.d.ts +2 -0
- package/dist/keyboard/focus-walk.js +1 -1
- package/dist/navigation/focus-loss.d.ts +39 -0
- package/dist/navigation/focus-loss.js +270 -0
- package/dist/navigation/record.d.ts +34 -0
- package/dist/navigation/record.js +15 -0
- package/dist/pill-menu.d.ts +2 -0
- package/dist/pill-menu.js +21 -2
- package/dist/provider.d.ts +14 -0
- package/dist/provider.js +72 -5
- package/dist/report/acr.js +8 -1
- package/dist/report/format.d.ts +9 -0
- package/dist/report/format.js +32 -0
- package/dist/report/headless.d.ts +10 -0
- package/dist/report/headless.js +162 -3
- package/dist/report/html.js +15 -1
- package/dist/report/wcag.js +2 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,45 @@
|
|
|
3
3
|
All notable changes to `@ngbracket/a11y-devtools` are documented here.
|
|
4
4
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## 0.20.0
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- Focus lost between scans. With `keyboard` on, the provider now watches for
|
|
11
|
+
the focused element being removed while focus falls back to the page body,
|
|
12
|
+
so the next Tab starts from the top of the page. Two new heuristic rules
|
|
13
|
+
report it against the component that owned the element, both under WCAG
|
|
14
|
+
2.4.3 Focus Order:
|
|
15
|
+
- `ngbr/focus-lost-on-rerender`: an `@if` or `@for` re-render removed the
|
|
16
|
+
focused element and nothing moved focus within 150ms. A dialog or menu
|
|
17
|
+
that returns focus to its trigger on close is not reported.
|
|
18
|
+
- `ngbr/focus-lost-on-navigation`: a route change removed the focused
|
|
19
|
+
element with the old view and left focus on the page body.
|
|
20
|
+
- The pill's menu lists the last 5 route changes: where focus went, whether
|
|
21
|
+
the page title changed, and what live regions announced. For example
|
|
22
|
+
"/orders → /orders/42: focus on body, title unchanged, nothing announced".
|
|
23
|
+
A route is the path and query string, plus the hash for hash routing
|
|
24
|
+
(`#/orders`).
|
|
25
|
+
- New provider options. `navigation: false` turns the watching off; it
|
|
26
|
+
follows `keyboard` by default. `focusTarget` is the CSS selector where
|
|
27
|
+
focus is expected after a route change (default
|
|
28
|
+
`'main, [role="main"], h1'`). It only labels the route-change list.
|
|
29
|
+
- `createFocusLossProbe` and `describeNavigation` are exported for use
|
|
30
|
+
outside the provider.
|
|
31
|
+
- Report mode has a new `--navigation` flag (`navigation: true` in
|
|
32
|
+
`scanPages`). After the scan it loads the first route, then moves to each
|
|
33
|
+
next route inside the app in the order given: it focuses a link to the
|
|
34
|
+
route and presses Enter, or changes the URL with `history.pushState` when
|
|
35
|
+
the page has no such link. Each route's report gets a "Route change"
|
|
36
|
+
section, and focus left on the page body is reported as
|
|
37
|
+
`ngbr/focus-lost-on-navigation`. With `--color-scheme both` it runs once.
|
|
38
|
+
A link that loads a new page is skipped with a warning, because that isn't
|
|
39
|
+
a route change inside the app.
|
|
40
|
+
- The ACR worksheet counts `ngbr/focus-lost-on-navigation` as a check for
|
|
41
|
+
2.4.3 Focus Order when the run used `--navigation`.
|
|
42
|
+
`ngbr/focus-lost-on-rerender` counts only when a report has its findings,
|
|
43
|
+
because only the in-app overlay sees a re-render.
|
|
44
|
+
|
|
6
45
|
## 0.19.0
|
|
7
46
|
|
|
8
47
|
### Added
|
package/README.md
CHANGED
|
@@ -33,6 +33,9 @@ Part of the `@ngbracket` Angular tooling family.
|
|
|
33
33
|
- Keyboard & Focus Mode: numbers the tab order, adds keyboard findings, shows the
|
|
34
34
|
Focus preview card (computed role, name and state), and finds keyboard traps by
|
|
35
35
|
pressing Tab for real.
|
|
36
|
+
- Focus lost between scans: reports a re-render or a route change that removes the
|
|
37
|
+
focused element and leaves focus on the page body, named after the component.
|
|
38
|
+
Report mode checks route changes too, with `--navigation`.
|
|
36
39
|
- Production weight: does nothing in production builds, and axe-core isn't loaded
|
|
37
40
|
there.
|
|
38
41
|
|
|
@@ -140,3 +143,4 @@ ever becomes reachable through a static import.
|
|
|
140
143
|
- Re-render a saved JSON report in any format without scanning (`--from`).
|
|
141
144
|
- Issue-count badge on the pill and a per-component filter in its menu.
|
|
142
145
|
- Tab order walkthrough in report mode (`--walkthrough`).
|
|
146
|
+
- Focus lost to a re-render or a route change, with a route-change list in the pill menu.
|
package/bin/ngbr-a11y-report.mjs
CHANGED
|
@@ -65,6 +65,11 @@ Options:
|
|
|
65
65
|
--walkthrough Also list each route's tab order with every stop's computed
|
|
66
66
|
role, name, states and component (an approximation, not
|
|
67
67
|
any one screen reader's output)
|
|
68
|
+
--navigation Also move between the routes inside the app, in the order
|
|
69
|
+
given, by focusing a link and pressing Enter (or with
|
|
70
|
+
history.pushState when there's no link). Records where
|
|
71
|
+
focus went and reports focus left on the page body
|
|
72
|
+
(ngbr/focus-lost-on-navigation). Needs 2 or more routes
|
|
68
73
|
--color-scheme <s> light | dark | both — scan with the browser emulating that
|
|
69
74
|
prefers-color-scheme (default light). "both" scans each
|
|
70
75
|
route twice; dark pages list only issues light doesn't have
|
|
@@ -104,6 +109,7 @@ function parseArgs(argv) {
|
|
|
104
109
|
case '--keyboard': opts.keyboard = true; break;
|
|
105
110
|
case '--focus-traps': opts.focusTraps = true; break;
|
|
106
111
|
case '--walkthrough': opts.walkthrough = true; break;
|
|
112
|
+
case '--navigation': opts.navigation = true; break;
|
|
107
113
|
case '--color-scheme': opts.colorScheme = next(); break;
|
|
108
114
|
case '--dark-class': opts.darkClass = next(); break;
|
|
109
115
|
case '--dark-attribute': opts.darkAttribute = next(); break;
|
|
@@ -122,7 +128,7 @@ const opts = parseArgs(process.argv.slice(2));
|
|
|
122
128
|
const SCAN_ONLY = {
|
|
123
129
|
base: '--base', serve: '--serve', serveTimeout: '--serve-timeout', routes: '--route', tags: '--tags',
|
|
124
130
|
wait: '--wait', frameworkPrefixes: '--framework-prefixes / --no-skip-primitives', keyboard: '--keyboard',
|
|
125
|
-
focusTraps: '--focus-traps', walkthrough: '--walkthrough', colorScheme: '--color-scheme', darkClass: '--dark-class',
|
|
131
|
+
focusTraps: '--focus-traps', walkthrough: '--walkthrough', navigation: '--navigation', colorScheme: '--color-scheme', darkClass: '--dark-class',
|
|
126
132
|
darkAttribute: '--dark-attribute', headed: '--headed',
|
|
127
133
|
};
|
|
128
134
|
if (opts.from && !opts.help) {
|
|
@@ -165,6 +171,11 @@ if (!opts.out && (formats.has('acr') || formats.has('acr-md'))) {
|
|
|
165
171
|
process.exit(2);
|
|
166
172
|
}
|
|
167
173
|
|
|
174
|
+
if (opts.navigation && opts.routes.length < 2) {
|
|
175
|
+
process.stderr.write('--navigation moves from one route to the next: give 2 or more --route\n');
|
|
176
|
+
process.exit(2);
|
|
177
|
+
}
|
|
178
|
+
|
|
168
179
|
if (opts.colorScheme && !['light', 'dark', 'both'].includes(opts.colorScheme)) {
|
|
169
180
|
process.stderr.write(`Invalid --color-scheme "${opts.colorScheme}" (use light, dark or both)\n`);
|
|
170
181
|
process.exit(2);
|
|
@@ -251,6 +262,7 @@ if (!report) {
|
|
|
251
262
|
keyboard: opts.keyboard,
|
|
252
263
|
focusTraps: opts.focusTraps,
|
|
253
264
|
walkthrough: opts.walkthrough,
|
|
265
|
+
navigation: opts.navigation,
|
|
254
266
|
colorScheme: opts.colorScheme,
|
|
255
267
|
darkClass: opts.darkClass,
|
|
256
268
|
darkAttribute,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { logFindings, type Logger } from './report.js';
|
|
|
5
5
|
export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, resolveListenerEvents, DEFAULT_FRAMEWORK_PREFIXES, ngDebug, type NgDebugGlobal, type NgListener, } from './attribution.js';
|
|
6
6
|
export { tabSequence, hasFocusableDescendant, isTabbable, isNativelyFocusable, resolvedTabIndex, visualOrderJumps, type TabStop, type TabSequenceOptions, type StopRect, } from './keyboard/tab-sequence.js';
|
|
7
7
|
export { scanKeyboard, type KeyboardScanOptions } from './keyboard/keyboard-scan.js';
|
|
8
|
+
export { createFocusLossProbe, describeNavigation, DEFAULT_FOCUS_TARGET, type FocusLossProbe, type FocusLossProbeOptions, type NavigationFocus, type NavigationRecord, } from './navigation/focus-loss.js';
|
|
8
9
|
export { findUncontainedModals, type UncontainedModal } from './keyboard/focus-trap.js';
|
|
9
10
|
export { createFocusWalkProbe, detectTabTrap, type FocusObservation, type FocusWalkProbe, type TabWalkVerdict, } from './keyboard/focus-walk.js';
|
|
10
11
|
export { describeElement, accessibleDescription, ariaStates, type AxDescription, } from './keyboard/accname.js';
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { logFindings } from './report.js';
|
|
|
5
5
|
export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, resolveListenerEvents, DEFAULT_FRAMEWORK_PREFIXES, ngDebug, } from './attribution.js';
|
|
6
6
|
export { tabSequence, hasFocusableDescendant, isTabbable, isNativelyFocusable, resolvedTabIndex, visualOrderJumps, } from './keyboard/tab-sequence.js';
|
|
7
7
|
export { scanKeyboard } from './keyboard/keyboard-scan.js';
|
|
8
|
+
export { createFocusLossProbe, describeNavigation, DEFAULT_FOCUS_TARGET, } from './navigation/focus-loss.js';
|
|
8
9
|
export { findUncontainedModals } from './keyboard/focus-trap.js';
|
|
9
10
|
export { createFocusWalkProbe, detectTabTrap, } from './keyboard/focus-walk.js';
|
|
10
11
|
export { describeElement, accessibleDescription, ariaStates, } from './keyboard/accname.js';
|
package/dist/inpage.global.js
CHANGED
|
@@ -35080,7 +35080,9 @@
|
|
|
35080
35080
|
"ngbr/drag-without-keyboard": ["2.1.1", "2.5.7"],
|
|
35081
35081
|
"ngbr/tab-order-mismatch": ["2.4.3"],
|
|
35082
35082
|
"ngbr/modal-focus-not-contained": ["2.4.3"],
|
|
35083
|
-
"ngbr/focus-trap": ["2.1.2"]
|
|
35083
|
+
"ngbr/focus-trap": ["2.1.2"],
|
|
35084
|
+
"ngbr/focus-lost-on-navigation": ["2.4.3"],
|
|
35085
|
+
"ngbr/focus-lost-on-rerender": ["2.4.3"]
|
|
35084
35086
|
};
|
|
35085
35087
|
function ngbrRuleCriteria(id) {
|
|
35086
35088
|
return [...NGBR_RULE_CRITERIA[id] ?? []];
|
|
@@ -35555,6 +35557,220 @@
|
|
|
35555
35557
|
};
|
|
35556
35558
|
}
|
|
35557
35559
|
|
|
35560
|
+
// dist/navigation/focus-loss.js
|
|
35561
|
+
var DEFAULT_FOCUS_TARGET = 'main, [role="main"], h1';
|
|
35562
|
+
var LIVE_REGION = [
|
|
35563
|
+
'[aria-live]:not([aria-live="off"])',
|
|
35564
|
+
'[role="status"]',
|
|
35565
|
+
'[role="alert"]',
|
|
35566
|
+
'[role="log"]',
|
|
35567
|
+
".cdk-live-announcer-element"
|
|
35568
|
+
].join(", ");
|
|
35569
|
+
function safeClosest(el, selector) {
|
|
35570
|
+
try {
|
|
35571
|
+
return el.closest(selector);
|
|
35572
|
+
} catch {
|
|
35573
|
+
return null;
|
|
35574
|
+
}
|
|
35575
|
+
}
|
|
35576
|
+
function createFocusLossProbe(doc = document, options = {}) {
|
|
35577
|
+
const prefixes = options.frameworkPrefixes ?? DEFAULT_FRAMEWORK_PREFIXES;
|
|
35578
|
+
const graceMs = options.graceMs ?? 150;
|
|
35579
|
+
const focusTarget = options.focusTarget ?? DEFAULT_FOCUS_TARGET;
|
|
35580
|
+
const route = options.route ?? (() => location.pathname + location.search + (location.hash.startsWith("#/") ? location.hash : ""));
|
|
35581
|
+
const records = [];
|
|
35582
|
+
const findings = [];
|
|
35583
|
+
const pending = /* @__PURE__ */ new Map();
|
|
35584
|
+
let focused;
|
|
35585
|
+
const focusByRoute = /* @__PURE__ */ new Map();
|
|
35586
|
+
let lastRoute = route();
|
|
35587
|
+
let lastTitle = doc.title;
|
|
35588
|
+
let navigating = false;
|
|
35589
|
+
const announced = [];
|
|
35590
|
+
const ANNOUNCE_WINDOW_MS = 2e3;
|
|
35591
|
+
const ours = (el) => el.closest(`[${OVERLAY_ATTR}]`) !== null;
|
|
35592
|
+
const onBody = (el) => !el || el === doc.body || el === doc.documentElement;
|
|
35593
|
+
function snapshot(element) {
|
|
35594
|
+
const componentPath = resolveComponentPath(element);
|
|
35595
|
+
const ancestors = [];
|
|
35596
|
+
for (let el = element.parentElement; el && el !== doc.body; el = el.parentElement)
|
|
35597
|
+
ancestors.push(el);
|
|
35598
|
+
return {
|
|
35599
|
+
element,
|
|
35600
|
+
ancestors,
|
|
35601
|
+
route: route(),
|
|
35602
|
+
component: appComponentFromPath(componentPath, prefixes),
|
|
35603
|
+
componentPath,
|
|
35604
|
+
directives: resolveDirectiveNames(element),
|
|
35605
|
+
target: shortSelector(element),
|
|
35606
|
+
html: shortHtml(element)
|
|
35607
|
+
};
|
|
35608
|
+
}
|
|
35609
|
+
function later(fn) {
|
|
35610
|
+
let done;
|
|
35611
|
+
const promise = new Promise((resolve) => done = resolve);
|
|
35612
|
+
const timer = setTimeout(() => {
|
|
35613
|
+
try {
|
|
35614
|
+
fn();
|
|
35615
|
+
} finally {
|
|
35616
|
+
pending.delete(promise);
|
|
35617
|
+
done();
|
|
35618
|
+
}
|
|
35619
|
+
}, graceMs);
|
|
35620
|
+
pending.set(promise, { timer, done });
|
|
35621
|
+
}
|
|
35622
|
+
function report(snap, id, help, page, box) {
|
|
35623
|
+
const anchor = box ? snap.ancestors.find((el) => el.isConnected) : void 0;
|
|
35624
|
+
const finding = {
|
|
35625
|
+
id,
|
|
35626
|
+
impact: "moderate",
|
|
35627
|
+
help,
|
|
35628
|
+
helpUrl: `${RULE_DOCS}/${id.slice("ngbr/".length)}`,
|
|
35629
|
+
wcag: ngbrRuleCriteria(id),
|
|
35630
|
+
component: snap.component,
|
|
35631
|
+
componentPath: snap.componentPath,
|
|
35632
|
+
directives: snap.directives,
|
|
35633
|
+
target: snap.target,
|
|
35634
|
+
locator: anchor ? uniqueLocator(anchor) ?? shortSelector(anchor) : void 0,
|
|
35635
|
+
html: snap.html
|
|
35636
|
+
};
|
|
35637
|
+
findings.push(finding);
|
|
35638
|
+
options.onFinding?.(finding, page);
|
|
35639
|
+
}
|
|
35640
|
+
const onFocusIn = (event) => {
|
|
35641
|
+
const el = event.composedPath()[0] ?? event.target;
|
|
35642
|
+
if (!(el instanceof Element) || onBody(el) || ours(el))
|
|
35643
|
+
return;
|
|
35644
|
+
focused = snapshot(el);
|
|
35645
|
+
focusByRoute.set(focused.route, focused);
|
|
35646
|
+
};
|
|
35647
|
+
const onFocusOut = (event) => {
|
|
35648
|
+
if (event.relatedTarget)
|
|
35649
|
+
return;
|
|
35650
|
+
const snap = focused;
|
|
35651
|
+
if (!snap)
|
|
35652
|
+
return;
|
|
35653
|
+
queueMicrotask(() => {
|
|
35654
|
+
if (focused !== snap || !snap.element.isConnected || !onBody(deepActiveElement(doc)))
|
|
35655
|
+
return;
|
|
35656
|
+
focused = void 0;
|
|
35657
|
+
if (focusByRoute.get(snap.route) === snap)
|
|
35658
|
+
focusByRoute.delete(snap.route);
|
|
35659
|
+
});
|
|
35660
|
+
};
|
|
35661
|
+
function checkRemoval() {
|
|
35662
|
+
const snap = focused;
|
|
35663
|
+
if (!snap || snap.element.isConnected)
|
|
35664
|
+
return;
|
|
35665
|
+
focused = void 0;
|
|
35666
|
+
later(() => {
|
|
35667
|
+
if (route() !== snap.route || navigating)
|
|
35668
|
+
return;
|
|
35669
|
+
if (!onBody(deepActiveElement(doc)))
|
|
35670
|
+
return;
|
|
35671
|
+
snap.reported = true;
|
|
35672
|
+
report(snap, "ngbr/focus-lost-on-rerender", `Focus was lost when this element was removed: it had focus, a re-render took it out of the page, and focus fell back to the page body, so the next Tab starts from the top. Move focus to a sensible place before removing it (the next item, the list, or a heading). Heuristic \u2014 verify manually.`, snap.route, true);
|
|
35673
|
+
});
|
|
35674
|
+
}
|
|
35675
|
+
function logAnnouncements(mutations) {
|
|
35676
|
+
const regions = /* @__PURE__ */ new Set();
|
|
35677
|
+
for (const m of mutations) {
|
|
35678
|
+
const el = m.target instanceof Element ? m.target : m.target.parentElement;
|
|
35679
|
+
if (!el || ours(el))
|
|
35680
|
+
continue;
|
|
35681
|
+
const region = safeClosest(el, LIVE_REGION);
|
|
35682
|
+
if (region && !(m.type === "childList" && [...m.addedNodes].some((n) => n === region || n.contains(region)))) {
|
|
35683
|
+
regions.add(region);
|
|
35684
|
+
}
|
|
35685
|
+
}
|
|
35686
|
+
for (const region of regions) {
|
|
35687
|
+
const text = region.textContent?.replace(/\s+/g, " ").trim();
|
|
35688
|
+
if (text)
|
|
35689
|
+
announced.push({ text: text.length > 200 ? `${text.slice(0, 199)}\u2026` : text, time: Date.now() });
|
|
35690
|
+
}
|
|
35691
|
+
if (announced.length > 50)
|
|
35692
|
+
announced.splice(0, announced.length - 50);
|
|
35693
|
+
}
|
|
35694
|
+
const observer = new MutationObserver((mutations) => {
|
|
35695
|
+
logAnnouncements(mutations);
|
|
35696
|
+
checkRemoval();
|
|
35697
|
+
});
|
|
35698
|
+
observer.observe(doc.documentElement, { childList: true, subtree: true, characterData: true });
|
|
35699
|
+
doc.addEventListener("focusin", onFocusIn, true);
|
|
35700
|
+
doc.addEventListener("focusout", onFocusOut, true);
|
|
35701
|
+
const initial = deepActiveElement(doc);
|
|
35702
|
+
if (initial && !onBody(initial) && !ours(initial)) {
|
|
35703
|
+
focused = snapshot(initial);
|
|
35704
|
+
focusByRoute.set(focused.route, focused);
|
|
35705
|
+
}
|
|
35706
|
+
function notifyStable() {
|
|
35707
|
+
if (navigating)
|
|
35708
|
+
return;
|
|
35709
|
+
if (route() === lastRoute) {
|
|
35710
|
+
lastTitle = doc.title;
|
|
35711
|
+
return;
|
|
35712
|
+
}
|
|
35713
|
+
navigating = true;
|
|
35714
|
+
const from = lastRoute;
|
|
35715
|
+
const titleBefore = lastTitle;
|
|
35716
|
+
const before = focusByRoute.get(from);
|
|
35717
|
+
const since = Date.now() - ANNOUNCE_WINDOW_MS;
|
|
35718
|
+
later(() => {
|
|
35719
|
+
navigating = false;
|
|
35720
|
+
const to = route();
|
|
35721
|
+
lastRoute = to;
|
|
35722
|
+
lastTitle = doc.title;
|
|
35723
|
+
for (const key of [...focusByRoute.keys()])
|
|
35724
|
+
if (key !== to)
|
|
35725
|
+
focusByRoute.delete(key);
|
|
35726
|
+
if (to === from)
|
|
35727
|
+
return;
|
|
35728
|
+
const active = deepActiveElement(doc);
|
|
35729
|
+
const lost = onBody(active);
|
|
35730
|
+
const focus = lost ? "body" : active && safeClosest(active, focusTarget) ? "target" : "other";
|
|
35731
|
+
const record = {
|
|
35732
|
+
from,
|
|
35733
|
+
to,
|
|
35734
|
+
focus,
|
|
35735
|
+
focusedTarget: lost || !active ? null : shortSelector(active),
|
|
35736
|
+
focusedComponent: lost || !active ? null : appComponentFromPath(resolveComponentPath(active), prefixes),
|
|
35737
|
+
focusBefore: before?.target ?? null,
|
|
35738
|
+
titleBefore,
|
|
35739
|
+
titleAfter: doc.title,
|
|
35740
|
+
titleChanged: doc.title !== titleBefore,
|
|
35741
|
+
// What was announced from just before the app settled. An announcer may
|
|
35742
|
+
// speak just before the URL updates, so the route isn't checked.
|
|
35743
|
+
announcements: announced.filter((a) => a.time >= since).map((a) => a.text)
|
|
35744
|
+
};
|
|
35745
|
+
announced.length = 0;
|
|
35746
|
+
records.push(record);
|
|
35747
|
+
options.onNavigation?.(record);
|
|
35748
|
+
if (lost && before && !before.element.isConnected && !before.reported) {
|
|
35749
|
+
report(before, "ngbr/focus-lost-on-navigation", `Focus was lost on the route change from ${from} to ${to}: the element that had focus went away with the old view, and focus fell back to the page body, so the next Tab starts from the top and a screen reader may say nothing. Move focus to the new view's heading or main region after navigation. Heuristic \u2014 verify manually.`, to, false);
|
|
35750
|
+
}
|
|
35751
|
+
});
|
|
35752
|
+
}
|
|
35753
|
+
return {
|
|
35754
|
+
notifyStable,
|
|
35755
|
+
async settled() {
|
|
35756
|
+
while (pending.size)
|
|
35757
|
+
await Promise.all([...pending.keys()]);
|
|
35758
|
+
},
|
|
35759
|
+
records: () => [...records],
|
|
35760
|
+
findings: () => [...findings],
|
|
35761
|
+
stop() {
|
|
35762
|
+
observer.disconnect();
|
|
35763
|
+
doc.removeEventListener("focusin", onFocusIn, true);
|
|
35764
|
+
doc.removeEventListener("focusout", onFocusOut, true);
|
|
35765
|
+
for (const { timer, done } of pending.values()) {
|
|
35766
|
+
clearTimeout(timer);
|
|
35767
|
+
done();
|
|
35768
|
+
}
|
|
35769
|
+
pending.clear();
|
|
35770
|
+
}
|
|
35771
|
+
};
|
|
35772
|
+
}
|
|
35773
|
+
|
|
35558
35774
|
// dist/keyboard/accname.js
|
|
35559
35775
|
var axePromise;
|
|
35560
35776
|
function loadAxe() {
|
|
@@ -35733,6 +35949,7 @@
|
|
|
35733
35949
|
globalThis.__ngbA11yScan = run;
|
|
35734
35950
|
globalThis.__ngbA11yCreateFocusProbe = (prefixes) => createFocusWalkProbe(document, prefixes);
|
|
35735
35951
|
globalThis.__ngbA11yWalkthrough = (prefixes) => linearWalkthrough(document, { frameworkPrefixes: prefixes });
|
|
35952
|
+
globalThis.__ngbA11yCreateFocusLossProbe = (prefixes) => createFocusLossProbe(document, { frameworkPrefixes: prefixes });
|
|
35736
35953
|
})();
|
|
35737
35954
|
/*! Bundled license information:
|
|
35738
35955
|
|
package/dist/inpage.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createFocusWalkProbe } from './keyboard/focus-walk.js';
|
|
2
|
+
import { createFocusLossProbe } from './navigation/focus-loss.js';
|
|
2
3
|
import { linearWalkthrough } from './keyboard/walkthrough.js';
|
|
3
4
|
import { scan } from './scan.js';
|
|
4
5
|
const run = (options, scanOptions) => scan(document, options, scanOptions);
|
|
@@ -8,3 +9,6 @@ globalThis.__ngbA11yScan = run;
|
|
|
8
9
|
globalThis.__ngbA11yCreateFocusProbe = (prefixes) => createFocusWalkProbe(document, prefixes);
|
|
9
10
|
// The linear walkthrough: the tab order with each stop's computed role and name.
|
|
10
11
|
globalThis.__ngbA11yWalkthrough = (prefixes) => linearWalkthrough(document, { frameworkPrefixes: prefixes });
|
|
12
|
+
// The route-change check: the driver moves between routes inside the app and
|
|
13
|
+
// asks the probe what happened to focus each time.
|
|
14
|
+
globalThis.__ngbA11yCreateFocusLossProbe = (prefixes) => createFocusLossProbe(document, { frameworkPrefixes: prefixes });
|
|
@@ -48,6 +48,8 @@ export interface FocusWalkProbe {
|
|
|
48
48
|
*/
|
|
49
49
|
trapFinding(cycle: readonly number[], shiftTabEscapes: boolean): A11yFinding | null;
|
|
50
50
|
}
|
|
51
|
+
/** The element that really has focus, through open shadow roots. */
|
|
52
|
+
export declare function deepActiveElement(doc: Document): Element | null;
|
|
51
53
|
/**
|
|
52
54
|
* Create the in-page probe. Ids are assigned on first sight and held in page
|
|
53
55
|
* memory only — the walk never writes to the DOM.
|
|
@@ -60,7 +60,7 @@ export function detectTabTrap(observations, collapsible = new Set()) {
|
|
|
60
60
|
/** The rule's page: what the message means, how to fix and check it, and WCAG 2.1.2. */
|
|
61
61
|
const FOCUS_TRAP_DOCS = 'https://ngbracket.com/tools/a11y-devtools/docs/focus-trap';
|
|
62
62
|
/** The element that really has focus, through open shadow roots. */
|
|
63
|
-
function deepActiveElement(doc) {
|
|
63
|
+
export function deepActiveElement(doc) {
|
|
64
64
|
let active = doc.activeElement;
|
|
65
65
|
while (active?.shadowRoot?.activeElement)
|
|
66
66
|
active = active.shadowRoot.activeElement;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { A11yFinding } from '../scan.js';
|
|
2
|
+
import type { NavigationRecord } from './record.js';
|
|
3
|
+
export type { NavigationFocus, NavigationRecord } from './record.js';
|
|
4
|
+
export { describeNavigation } from './record.js';
|
|
5
|
+
export interface FocusLossProbeOptions {
|
|
6
|
+
/** Component-name prefixes to walk past during attribution. */
|
|
7
|
+
frameworkPrefixes?: readonly string[];
|
|
8
|
+
/**
|
|
9
|
+
* How long to wait after a removal or a route change before checking focus,
|
|
10
|
+
* so a dialog or menu that restores focus on close has done so. Default 150ms.
|
|
11
|
+
*/
|
|
12
|
+
graceMs?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Where focus is expected to go after a route change. Only used to label the
|
|
15
|
+
* record (`target` / `other`); focus left on `<body>` is the only finding.
|
|
16
|
+
* Default `'main, [role="main"], h1'`.
|
|
17
|
+
*/
|
|
18
|
+
focusTarget?: string;
|
|
19
|
+
/** Called with each finding as it happens. */
|
|
20
|
+
onFinding?: (finding: A11yFinding, route: string) => void;
|
|
21
|
+
/** Called with each route change record. */
|
|
22
|
+
onNavigation?: (record: NavigationRecord) => void;
|
|
23
|
+
/** Current route. Defaults to `location.pathname + location.search`. */
|
|
24
|
+
route?: () => string;
|
|
25
|
+
}
|
|
26
|
+
export interface FocusLossProbe {
|
|
27
|
+
/** The host says the app has settled: check for a route change. */
|
|
28
|
+
notifyStable(): void;
|
|
29
|
+
/** Wait until no check is pending (tests and the headless driver). */
|
|
30
|
+
settled(): Promise<void>;
|
|
31
|
+
/** Route changes recorded so far, oldest first. */
|
|
32
|
+
records(): NavigationRecord[];
|
|
33
|
+
/** Findings reported so far, oldest first. */
|
|
34
|
+
findings(): A11yFinding[];
|
|
35
|
+
stop(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare const DEFAULT_FOCUS_TARGET = "main, [role=\"main\"], h1";
|
|
38
|
+
/** Start watching `doc` for focus lost to a removal or a route change. */
|
|
39
|
+
export declare function createFocusLossProbe(doc?: Document, options?: FocusLossProbeOptions): FocusLossProbe;
|