@ngbracket/a11y-devtools 0.15.5 → 0.15.7
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 +36 -0
- package/README.md +44 -37
- package/dist/inpage.global.js +12 -4
- package/dist/keyboard/accname.js +11 -5
- package/dist/overlay.d.ts +1 -1
- package/dist/overlay.js +23 -7
- package/dist/provider.js +63 -22
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
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.15.7
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- The keyboard tab-order badges now pass a colour contrast check. Their white
|
|
11
|
+
digits sat on a teal fill at 3.93:1, below the 4.5:1 that text this size
|
|
12
|
+
needs, and axe flagged them on a dark-mode page. The fill is now `#0a7a7a`
|
|
13
|
+
(5.15:1). The orange badge for a positive `tabindex` had the same problem
|
|
14
|
+
(3.09:1) and is now `#b45309` (5.02:1). The lines joining the badges keep
|
|
15
|
+
their teal.
|
|
16
|
+
- The finding labels now pass a colour contrast check too. Their white text
|
|
17
|
+
sat on the impact colour, which gave 2.42:1 to 4.11:1 for every impact except
|
|
18
|
+
critical. Labels now use a darker fill in the same hue: serious `#b45309`,
|
|
19
|
+
moderate `#8a6d00`, minor `#2563c4` and no impact `#666666`, all at least
|
|
20
|
+
4.9:1. The box outlines keep the original impact colours.
|
|
21
|
+
|
|
22
|
+
## 0.15.6
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **The Focus preview card is now headed "Focus preview".** It used to say
|
|
27
|
+
"Accessibility-tree preview", which didn't match the "Focus preview" setting
|
|
28
|
+
in the pill menu, so the card and its switch were hard to connect. It is
|
|
29
|
+
still labelled a computed approximation.
|
|
30
|
+
- **Turning Focus preview on shows the card without waiting for focus to
|
|
31
|
+
move.** Before, nothing appeared until focus next moved. Now, switching the
|
|
32
|
+
setting on describes the control that already has focus; switching the whole
|
|
33
|
+
tool on does the same once its first scan finishes. When you toggle it
|
|
34
|
+
from the pill menu, it describes the page control you were on before.
|
|
35
|
+
- **The Focus preview no longer shows an empty name while a scan is running.**
|
|
36
|
+
axe can't compute an accessible name during its own run, so a control
|
|
37
|
+
focused mid-scan showed "(no accessible name)". The preview now waits for the
|
|
38
|
+
scan to finish and describes only the latest focus. A `describeElement` call
|
|
39
|
+
made during a scan also no longer tears down the scan's axe tree, which had
|
|
40
|
+
silently dropped that scan's findings.
|
|
41
|
+
|
|
6
42
|
## 0.15.5
|
|
7
43
|
|
|
8
44
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
# @ngbracket/a11y-devtools
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Finds accessibility problems in Angular apps and names the component behind each one.
|
|
4
|
+
Use it as an overlay while you develop, or headless in CI. It runs axe-core, plus its
|
|
5
|
+
own keyboard checks if you turn them on, and groups the results by component:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
♿ UserCardComponent — 2 issue(s)
|
|
9
|
+
critical · image-alt: Images must have alternative text
|
|
10
|
+
serious · color-contrast: Elements must meet minimum color contrast ratio thresholds
|
|
11
|
+
```
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
Documentation: [ngbracket.com/tools/a11y-devtools/docs](https://ngbracket.com/tools/a11y-devtools/docs/introduction)
|
|
14
|
+
has the guides, every option and CLI flag, and the rule catalogue. You can also try the
|
|
15
|
+
[live demo](https://a11y-demo.ngbracket.com/a11y-demo) without installing anything.
|
|
9
16
|
|
|
10
17
|
Part of the `@ngbracket` Angular tooling family.
|
|
11
18
|
|
|
12
19
|
## Features
|
|
13
20
|
|
|
14
|
-
-
|
|
15
|
-
|
|
21
|
+
- Component attribution: every finding names the Angular component to fix. It skips
|
|
22
|
+
past UI-library components (Material, CDK, Nebular and others) to yours, using
|
|
16
23
|
Angular's documented dev debug API (`window.ng`).
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
Alt+Shift+A
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
- In-app provider: rescans each time the app settles, logs findings grouped by
|
|
25
|
+
component, and can draw an overlay on the page. Turn it on and off with the
|
|
26
|
+
on-page pill or Alt+Shift+A. The pill's menu picks what's drawn and downloads an
|
|
27
|
+
HTML report of the routes you've visited.
|
|
28
|
+
- Report mode: scans many routes headless from the CLI and writes Markdown, JSON
|
|
29
|
+
and a self-contained HTML report.
|
|
30
|
+
- CI gating with a baseline: fails only on new issues, so an app with known issues
|
|
31
|
+
can add the gate straight away.
|
|
32
|
+
- Dark mode: scans your dark theme too, however your app switches to it.
|
|
33
|
+
- Keyboard & Focus Mode: numbers the tab order, adds keyboard findings, shows the
|
|
34
|
+
Focus preview card (computed role, name and state), and finds keyboard traps by
|
|
35
|
+
pressing Tab for real.
|
|
36
|
+
- Production weight: does nothing in production builds, and axe-core isn't loaded
|
|
37
|
+
there.
|
|
31
38
|
|
|
32
39
|
## Install
|
|
33
40
|
|
|
@@ -38,7 +45,7 @@ npm i -D @ngbracket/a11y-devtools
|
|
|
38
45
|
npm i -D playwright && npx playwright install chromium
|
|
39
46
|
```
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
It needs Angular 18 or later.
|
|
42
49
|
|
|
43
50
|
## Quick start
|
|
44
51
|
|
|
@@ -56,8 +63,8 @@ export const appConfig: ApplicationConfig = {
|
|
|
56
63
|

|
|
61
68
|
|
|
62
69
|
In CI (`--serve` starts `ng serve`, waits for it, and stops it after the scan):
|
|
63
70
|
|
|
@@ -78,13 +85,13 @@ Next steps, in the docs:
|
|
|
78
85
|
[CLI reference](https://ngbracket.com/tools/a11y-devtools/docs/cli) ·
|
|
79
86
|
[Findings & rules](https://ngbracket.com/tools/a11y-devtools/docs/findings)
|
|
80
87
|
|
|
81
|
-
## What it
|
|
88
|
+
## What it leaves to you
|
|
82
89
|
|
|
83
|
-
Automated checks cover part of WCAG
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
[What it checks
|
|
90
|
+
Automated checks cover part of WCAG. The rest needs manual testing: keyboard, screen
|
|
91
|
+
reader, zoom and review by people. The keyboard findings are heuristics,
|
|
92
|
+
each labelled "verify manually". The tool helps you build toward supporting WCAG 2.2
|
|
93
|
+
AA; it doesn't certify conformance. See
|
|
94
|
+
[What it checks](https://ngbracket.com/tools/a11y-devtools/docs/coverage).
|
|
88
95
|
|
|
89
96
|
## Develop
|
|
90
97
|
|
|
@@ -111,13 +118,13 @@ ever becomes reachable through a static import.
|
|
|
111
118
|
|
|
112
119
|
### Planned
|
|
113
120
|
|
|
114
|
-
-
|
|
115
|
-
|
|
121
|
+
- A headless "linear walkthrough": the tab sequence as a reading list per route in
|
|
122
|
+
report mode. The Focus preview is overlay-only for now.
|
|
116
123
|
- Per-component filtering and a violation-count badge.
|
|
117
124
|
|
|
118
125
|
### Done
|
|
119
126
|
|
|
120
|
-
- Component attribution
|
|
127
|
+
- Component attribution: the nearest app-owned component, skipping UI primitives.
|
|
121
128
|
- Directive and `hostDirectives` attribution.
|
|
122
129
|
- Configurable framework prefixes.
|
|
123
130
|
- axe scan.
|
|
@@ -128,10 +135,10 @@ ever becomes reachable through a static import.
|
|
|
128
135
|
- HTML report output.
|
|
129
136
|
- Baseline/diff mode: CI fails only on new issues.
|
|
130
137
|
- Dark-mode scanning: `--color-scheme`, `--dark-class` / `--dark-attribute`, and theme-aware hooks.
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
|
|
138
|
+
- Keyboard & Focus Mode M1: tab-order visualisation and keyboard-reachability findings.
|
|
139
|
+
- Keyboard & Focus Mode M2: the focus-follow accessibility-tree preview (now called Focus preview).
|
|
140
|
+
- Keyboard & Focus Mode M3: missing focus-trap detection (an `aria-modal` that doesn't
|
|
141
|
+
contain focus) and the keyboard-trap walk with real Tab presses.
|
|
135
142
|
- CI production-weight guard.
|
|
136
143
|
- Real-browser E2E tests, including component attribution in a real Angular app.
|
|
137
144
|
- Report mode can start the dev server (`--serve`).
|
package/dist/inpage.global.js
CHANGED
|
@@ -34301,7 +34301,8 @@
|
|
|
34301
34301
|
// dist/overlay.js
|
|
34302
34302
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
34303
34303
|
var TAB_ORDER_COLOR = "#0b8f8f";
|
|
34304
|
-
var
|
|
34304
|
+
var TAB_BADGE_FILL = "#0a7a7a";
|
|
34305
|
+
var TAB_BADGE_WARN_FILL = "#b45309";
|
|
34305
34306
|
var TAB_BADGE_GUTTER = 10;
|
|
34306
34307
|
var TAB_BADGE_MIN_X = 9;
|
|
34307
34308
|
var LABEL_MIN_TOP = 2;
|
|
@@ -34314,6 +34315,13 @@
|
|
|
34314
34315
|
minor: "#3b7dd8",
|
|
34315
34316
|
none: "#8a8a8a"
|
|
34316
34317
|
};
|
|
34318
|
+
var IMPACT_LABEL_FILL = {
|
|
34319
|
+
critical: "#d32029",
|
|
34320
|
+
serious: "#b45309",
|
|
34321
|
+
moderate: "#8a6d00",
|
|
34322
|
+
minor: "#2563c4",
|
|
34323
|
+
none: "#666666"
|
|
34324
|
+
};
|
|
34317
34325
|
function colorFor(impact) {
|
|
34318
34326
|
return IMPACT_COLOR[impact ?? "none"];
|
|
34319
34327
|
}
|
|
@@ -34483,7 +34491,7 @@
|
|
|
34483
34491
|
function buildAxPanelContent(doc, data) {
|
|
34484
34492
|
const nodes = [];
|
|
34485
34493
|
const header = doc.createElement("div");
|
|
34486
|
-
header.textContent = "
|
|
34494
|
+
header.textContent = "Focus preview \u2014 computed approximation";
|
|
34487
34495
|
Object.assign(header.style, {
|
|
34488
34496
|
fontWeight: "700",
|
|
34489
34497
|
fontSize: "10px",
|
|
@@ -34517,7 +34525,7 @@
|
|
|
34517
34525
|
return nodes;
|
|
34518
34526
|
}
|
|
34519
34527
|
function buildBadge(doc, stop) {
|
|
34520
|
-
const color = stop.positive ?
|
|
34528
|
+
const color = stop.positive ? TAB_BADGE_WARN_FILL : TAB_BADGE_FILL;
|
|
34521
34529
|
const badge = doc.createElement("div");
|
|
34522
34530
|
badge.setAttribute("data-ngb-tab-order", String(stop.order));
|
|
34523
34531
|
const owner = stop.component ? ` \xB7 ${stop.component}` : "";
|
|
@@ -34574,7 +34582,7 @@
|
|
|
34574
34582
|
padding: "1px 4px",
|
|
34575
34583
|
font: "11px/1.4 ui-monospace, monospace",
|
|
34576
34584
|
color: "#fff",
|
|
34577
|
-
background:
|
|
34585
|
+
background: IMPACT_LABEL_FILL[finding.impact ?? "none"],
|
|
34578
34586
|
whiteSpace: "nowrap"
|
|
34579
34587
|
});
|
|
34580
34588
|
box.appendChild(label);
|
package/dist/keyboard/accname.js
CHANGED
|
@@ -30,8 +30,10 @@ export async function describeElement(element) {
|
|
|
30
30
|
const doc = element.ownerDocument ?? document;
|
|
31
31
|
let role = null;
|
|
32
32
|
let name = '';
|
|
33
|
+
let didSetup = false;
|
|
33
34
|
try {
|
|
34
35
|
axe.setup(doc);
|
|
36
|
+
didSetup = true;
|
|
35
37
|
const vnode = axe.utils.getNodeFromTree(element);
|
|
36
38
|
role = axe.commons.aria.getRole(element) ?? null;
|
|
37
39
|
name = vnode ? (axe.commons.text.accessibleTextVirtual(vnode) ?? '') : '';
|
|
@@ -40,11 +42,15 @@ export async function describeElement(element) {
|
|
|
40
42
|
// Leave role=null / name='' — axe couldn't build a tree (e.g. run in flight).
|
|
41
43
|
}
|
|
42
44
|
finally {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
// Only tear down our own setup: a failed setup means a scan owns axe's tree,
|
|
46
|
+
// and tearing that down would silently drop the scan's findings.
|
|
47
|
+
if (didSetup) {
|
|
48
|
+
try {
|
|
49
|
+
axe.teardown();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
/* nothing set up */
|
|
53
|
+
}
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
return { role, name, description: accessibleDescription(element), states: ariaStates(element) };
|
package/dist/overlay.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface A11yOverlay {
|
|
|
24
24
|
*/
|
|
25
25
|
renderTabOrder(stops: TabStop[]): void;
|
|
26
26
|
/**
|
|
27
|
-
* Show the accessibility-tree
|
|
27
|
+
* Show the Focus preview panel (an accessibility-tree approximation) for the focused element, or hide it
|
|
28
28
|
* when passed `null`. Deliberately framed as a *computed approximation* — see
|
|
29
29
|
* the panel header — never as verbatim screen-reader output.
|
|
30
30
|
*/
|
package/dist/overlay.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { keepInTopLayer } from './top-layer.js';
|
|
2
2
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
3
|
-
/** Tab-order
|
|
3
|
+
/** Tab-order connector line colour (teal). */
|
|
4
4
|
const TAB_ORDER_COLOR = '#0b8f8f';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Badge fills behind white 10px digits: at least 4.5:1 with white (teal 5.15,
|
|
7
|
+
* orange 5.02). The orange marks a positive-tabindex stop.
|
|
8
|
+
*/
|
|
9
|
+
const TAB_BADGE_FILL = '#0a7a7a';
|
|
10
|
+
const TAB_BADGE_WARN_FILL = '#b45309';
|
|
6
11
|
/** How far outside a control's left edge the tab-order badge sits, and its min viewport x. */
|
|
7
12
|
const TAB_BADGE_GUTTER = 10;
|
|
8
13
|
const TAB_BADGE_MIN_X = 9;
|
|
@@ -23,6 +28,17 @@ const IMPACT_COLOR = {
|
|
|
23
28
|
minor: '#3b7dd8',
|
|
24
29
|
none: '#8a8a8a',
|
|
25
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Label fill per impact, behind white 11px text: at least 4.5:1 with white, in
|
|
33
|
+
* the same hue as the border, so the labels pass a contrast check themselves.
|
|
34
|
+
*/
|
|
35
|
+
const IMPACT_LABEL_FILL = {
|
|
36
|
+
critical: '#d32029',
|
|
37
|
+
serious: '#b45309',
|
|
38
|
+
moderate: '#8a6d00',
|
|
39
|
+
minor: '#2563c4',
|
|
40
|
+
none: '#666666',
|
|
41
|
+
};
|
|
26
42
|
function colorFor(impact) {
|
|
27
43
|
return IMPACT_COLOR[impact ?? 'none'];
|
|
28
44
|
}
|
|
@@ -74,7 +90,7 @@ export function createOverlay(options = {}) {
|
|
|
74
90
|
connector.setAttribute('opacity', '0.7');
|
|
75
91
|
svg.appendChild(connector);
|
|
76
92
|
container.appendChild(svg); // under the badges, which are appended later
|
|
77
|
-
// The
|
|
93
|
+
// The Focus preview panel: a fixed card that follows focus. Hidden
|
|
78
94
|
// until renderAxPanel is called with data. Marked with OVERLAY_ATTR so scans
|
|
79
95
|
// never flag the tool's own UI.
|
|
80
96
|
const axPanel = doc.createElement('div');
|
|
@@ -223,11 +239,11 @@ export function createOverlay(options = {}) {
|
|
|
223
239
|
}
|
|
224
240
|
return { render, renderTabOrder, renderAxPanel, clear, clearTabOrder, destroy };
|
|
225
241
|
}
|
|
226
|
-
/** The rows of the
|
|
242
|
+
/** The rows of the Focus preview panel, honesty header first. */
|
|
227
243
|
function buildAxPanelContent(doc, data) {
|
|
228
244
|
const nodes = [];
|
|
229
245
|
const header = doc.createElement('div');
|
|
230
|
-
header.textContent = '
|
|
246
|
+
header.textContent = 'Focus preview — computed approximation';
|
|
231
247
|
Object.assign(header.style, {
|
|
232
248
|
fontWeight: '700',
|
|
233
249
|
fontSize: '10px',
|
|
@@ -268,7 +284,7 @@ function buildAxPanelContent(doc, data) {
|
|
|
268
284
|
* positive tabindex hijacks the natural order.
|
|
269
285
|
*/
|
|
270
286
|
function buildBadge(doc, stop) {
|
|
271
|
-
const color = stop.positive ?
|
|
287
|
+
const color = stop.positive ? TAB_BADGE_WARN_FILL : TAB_BADGE_FILL;
|
|
272
288
|
const badge = doc.createElement('div');
|
|
273
289
|
badge.setAttribute('data-ngb-tab-order', String(stop.order));
|
|
274
290
|
const owner = stop.component ? ` · ${stop.component}` : '';
|
|
@@ -328,7 +344,7 @@ function buildBox(doc, finding) {
|
|
|
328
344
|
padding: '1px 4px',
|
|
329
345
|
font: '11px/1.4 ui-monospace, monospace',
|
|
330
346
|
color: '#fff',
|
|
331
|
-
background:
|
|
347
|
+
background: IMPACT_LABEL_FILL[finding.impact ?? 'none'],
|
|
332
348
|
whiteSpace: 'nowrap',
|
|
333
349
|
});
|
|
334
350
|
box.appendChild(label);
|
package/dist/provider.js
CHANGED
|
@@ -82,21 +82,37 @@ function devtoolsProviders(options) {
|
|
|
82
82
|
if (!settings.focusPreview)
|
|
83
83
|
overlayView.renderAxPanel(null);
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* On turning the preview (or the tool) on, describe what's already focused —
|
|
87
|
+
* or, when focus is in our own pill menu (the toggle was just clicked), the
|
|
88
|
+
* page control that had focus before it.
|
|
89
|
+
*/
|
|
90
|
+
function previewCurrentFocus() {
|
|
91
|
+
const active = document.activeElement;
|
|
92
|
+
const ours = active instanceof Element && active.closest(`[${OVERLAY_ATTR}]`);
|
|
93
|
+
previewFocus(ours ? (lastPageFocus?.isConnected ? lastPageFocus : null) : active);
|
|
94
|
+
}
|
|
85
95
|
const setEnabled = (next) => {
|
|
86
96
|
if (next === enabled)
|
|
87
97
|
return;
|
|
88
98
|
enabled = next;
|
|
89
99
|
writeStoredEnabled(storage, enabled);
|
|
90
100
|
pillView?.setEnabled(enabled);
|
|
91
|
-
if (enabled)
|
|
101
|
+
if (enabled) {
|
|
92
102
|
scanNow(); // don't wait for the app's next stable moment
|
|
93
|
-
|
|
103
|
+
previewCurrentFocus();
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
94
106
|
draw();
|
|
107
|
+
}
|
|
95
108
|
};
|
|
96
109
|
const setSettings = (next) => {
|
|
110
|
+
const previewTurnedOn = next.focusPreview && !settings.focusPreview;
|
|
97
111
|
settings = next;
|
|
98
112
|
writeStoredSettings(storage, settings, defaultSettings);
|
|
99
113
|
draw();
|
|
114
|
+
if (previewTurnedOn)
|
|
115
|
+
previewCurrentFocus();
|
|
100
116
|
};
|
|
101
117
|
const downloadReport = () => {
|
|
102
118
|
import('./report/html.js')
|
|
@@ -139,38 +155,63 @@ function devtoolsProviders(options) {
|
|
|
139
155
|
// the ~2/3 axe can't test — attributed to its component. Needs the visual
|
|
140
156
|
// overlay; shown while the Focus preview setting is on.
|
|
141
157
|
let onFocusIn;
|
|
158
|
+
// The last page control (not our own UI) that had focus, for previewCurrentFocus.
|
|
159
|
+
let lastPageFocus;
|
|
142
160
|
if (overlayView) {
|
|
143
161
|
onFocusIn = (event) => {
|
|
144
|
-
if (!enabled || !settings.focusPreview)
|
|
145
|
-
return;
|
|
146
162
|
const el = event.target;
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.then((desc) => {
|
|
151
|
-
if (!enabled || !settings.focusPreview)
|
|
152
|
-
return; // switched off while describing
|
|
153
|
-
overlayView.renderAxPanel({
|
|
154
|
-
...desc,
|
|
155
|
-
component: resolveOwningComponentName(el, frameworkPrefixes),
|
|
156
|
-
tag: el.tagName.toLowerCase(),
|
|
157
|
-
});
|
|
158
|
-
})
|
|
159
|
-
.catch(() => undefined);
|
|
163
|
+
if (el instanceof Element && !el.closest(`[${OVERLAY_ATTR}]`))
|
|
164
|
+
lastPageFocus = el;
|
|
165
|
+
previewFocus(el);
|
|
160
166
|
};
|
|
161
167
|
document.addEventListener('focusin', onFocusIn, true);
|
|
162
168
|
}
|
|
163
|
-
|
|
169
|
+
// Bumped on every preview request, so only the latest focus is described.
|
|
170
|
+
let previewGen = 0;
|
|
171
|
+
/** Show the Focus preview card for `el`, unless it's our own UI or the page body. */
|
|
172
|
+
function previewFocus(el) {
|
|
173
|
+
if (!overlayView || !enabled || !settings.focusPreview)
|
|
174
|
+
return;
|
|
175
|
+
if (!(el instanceof Element) || el === document.body || el === document.documentElement)
|
|
176
|
+
return;
|
|
177
|
+
if (el.closest(`[${OVERLAY_ATTR}]`))
|
|
178
|
+
return; // skip our own UI
|
|
179
|
+
const gen = ++previewGen;
|
|
180
|
+
const stale = () => gen !== previewGen || !enabled || !settings.focusPreview;
|
|
181
|
+
// axe can't build an accname tree while a scan has it set up, so wait
|
|
182
|
+
// until no scan is running rather than show an empty name.
|
|
183
|
+
scansIdle()
|
|
184
|
+
.then(() => (stale() || !el.isConnected ? null : describeElement(el)))
|
|
185
|
+
.then((desc) => {
|
|
186
|
+
if (!desc || stale())
|
|
187
|
+
return; // focus moved on, or switched off while waiting
|
|
188
|
+
overlayView.renderAxPanel({
|
|
189
|
+
...desc,
|
|
190
|
+
component: resolveOwningComponentName(el, frameworkPrefixes),
|
|
191
|
+
tag: el.tagName.toLowerCase(),
|
|
192
|
+
});
|
|
193
|
+
})
|
|
194
|
+
.catch(() => undefined);
|
|
195
|
+
}
|
|
196
|
+
let currentScan;
|
|
164
197
|
let rescanQueued = false;
|
|
198
|
+
/**
|
|
199
|
+
* Resolves once no scan is running (a queued rescan starts as one ends).
|
|
200
|
+
* Gives up after a few back-to-back scans, so an app that keeps re-settling
|
|
201
|
+
* can't hold the preview back for ever.
|
|
202
|
+
*/
|
|
203
|
+
async function scansIdle() {
|
|
204
|
+
for (let waits = 0; currentScan && waits < 3; waits++)
|
|
205
|
+
await currentScan;
|
|
206
|
+
}
|
|
165
207
|
function scanNow() {
|
|
166
208
|
if (!enabled)
|
|
167
209
|
return;
|
|
168
|
-
if (
|
|
210
|
+
if (currentScan) {
|
|
169
211
|
rescanQueued = true; // don't stack scans; run one more when this finishes
|
|
170
212
|
return;
|
|
171
213
|
}
|
|
172
|
-
|
|
173
|
-
runA11yScan(root?.(), { log, logger, axe, frameworkPrefixes, keyboard })
|
|
214
|
+
currentScan = runA11yScan(root?.(), { log, logger, axe, frameworkPrefixes, keyboard })
|
|
174
215
|
.then((findings) => {
|
|
175
216
|
if (!enabled)
|
|
176
217
|
return; // switched off mid-scan: draw nothing
|
|
@@ -182,7 +223,7 @@ function devtoolsProviders(options) {
|
|
|
182
223
|
})
|
|
183
224
|
.catch(() => undefined)
|
|
184
225
|
.finally(() => {
|
|
185
|
-
|
|
226
|
+
currentScan = undefined;
|
|
186
227
|
if (rescanQueued) {
|
|
187
228
|
rescanQueued = false;
|
|
188
229
|
scanNow();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.15.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.15.7",
|
|
4
|
+
"description": "Finds accessibility problems in Angular apps and names the component behind each one. A dev overlay, or headless reports for CI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Duncan Faulkner",
|
|
7
7
|
"contributors": [
|