@ngbracket/a11y-devtools 0.10.0 → 0.11.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 +47 -0
- package/README.md +51 -330
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/inpage.global.js +621 -604
- package/dist/keyboard/keyboard-scan.js +6 -1
- package/dist/keyboard/tab-sequence.d.ts +27 -8
- package/dist/keyboard/tab-sequence.js +43 -9
- package/dist/provider.d.ts +17 -0
- package/dist/provider.js +66 -11
- package/dist/report/baseline.d.ts +4 -1
- package/dist/report/baseline.js +6 -1
- package/dist/report/format.js +4 -0
- package/dist/toggle.d.ts +61 -0
- package/dist/toggle.js +173 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,53 @@
|
|
|
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.11.0
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- **Turn the devtools on and off without changing code.** An on/off pill sits in
|
|
11
|
+
the bottom-left corner, and **Alt+Shift+A** does the same from the keyboard. Off
|
|
12
|
+
means no scanning and nothing drawn, so it costs nothing while hidden. The choice
|
|
13
|
+
is remembered in `localStorage`, so it stays off across reloads until you turn it
|
|
14
|
+
back on.
|
|
15
|
+
- New provider options: `enabled` (the starting state before a developer has
|
|
16
|
+
chosen; default `true`), `pill` (a corner, or `false` to hide it; default
|
|
17
|
+
`'bottom-left'`) and `shortcut` (e.g. `'Ctrl+Alt+K'`, or `false`; default
|
|
18
|
+
`'Alt+Shift+A'`). Letter and digit shortcuts match the physical key, so
|
|
19
|
+
Alt/Option combinations work on macOS.
|
|
20
|
+
- The pill is a `role="switch"` button with visible on/off text and a 28px
|
|
21
|
+
target. It's excluded from scans and from the tab-order layer, like the rest of
|
|
22
|
+
the overlay. New exports: `createTogglePill`, `parseShortcut`, `matchesShortcut`,
|
|
23
|
+
`formatShortcut`, `readStoredEnabled`, `writeStoredEnabled`,
|
|
24
|
+
`DEFAULT_TOGGLE_SHORTCUT`, `TOGGLE_STORAGE_KEY` and their types.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- `tabSequence` leaves out elements inside the overlay's own UI
|
|
29
|
+
(`[data-ngb-a11y-overlay]`), so the pill never appears as a tab stop or counts
|
|
30
|
+
as focus escaping a modal.
|
|
31
|
+
|
|
32
|
+
## 0.10.1
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **The JSON report now keeps a failed route's `error`.** Before, a route that
|
|
37
|
+
failed to scan appeared in the JSON as a page with 0 findings, which looks clean.
|
|
38
|
+
Pages now also carry `colorScheme` and `darkOnly` when set.
|
|
39
|
+
- **Baseline: a route that failed in the baseline is skipped** instead of counting
|
|
40
|
+
everything on it as new. Re-record the baseline to cover it.
|
|
41
|
+
- **`ngbr/tab-order-mismatch` no longer flags moving into the next column.** Tab
|
|
42
|
+
going up *and to the right* (from a sidebar into the main content, or across a
|
|
43
|
+
multi-column footer) is normal reading order. Up-and-left, and leftwards on the
|
|
44
|
+
same row, are still flagged. It also now compares where the previous stop *ends*
|
|
45
|
+
with where the next *starts*, using line boxes, so links in wrapped paragraph text
|
|
46
|
+
aren't misread. Found by running the tool on its own docs site. New export type:
|
|
47
|
+
`StopRect`.
|
|
48
|
+
- **`ngbr/unreachable-control` / `ngbr/click-without-key` skip event delegation.** A
|
|
49
|
+
click listener on a container of links or controls (with no interactive role of
|
|
50
|
+
its own) handles clicks on those controls; it isn't a fake button. New export:
|
|
51
|
+
`hasFocusableDescendant`.
|
|
52
|
+
|
|
6
53
|
## 0.10.0
|
|
7
54
|
|
|
8
55
|
### Added
|
package/README.md
CHANGED
|
@@ -1,375 +1,96 @@
|
|
|
1
1
|
# @ngbracket/a11y-devtools
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Accessibility auditing for Angular that maps each axe violation back to **the
|
|
4
|
+
component that rendered it**, so you get `♿ UserCardComponent — 2 issue(s)`, not a
|
|
5
|
+
wall of CSS selectors. Run it as a dev overlay while you build, or headless in CI.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[TanStack's a11y plugin](https://tanstack.com/devtools/latest/docs/plugins/a11y)
|
|
10
|
-
(now cross-framework, with an Angular adapter too) — report the DOM node (selector,
|
|
11
|
-
HTML, rule id) and highlight it, but we haven't seen one tie a violation back to the
|
|
12
|
-
component that rendered it, by name. This does, through Angular's **documented** dev
|
|
13
|
-
debug API (`window.ng`) rather than private framework internals.
|
|
7
|
+
**📖 Documentation: [ngbracket.com/tools/a11y-devtools/docs](https://ngbracket.com/tools/a11y-devtools/docs/introduction)**
|
|
8
|
+
(guides, every option and CLI flag, and the rule catalogue).
|
|
14
9
|
|
|
15
10
|
Part of the `@ngbracket` Angular tooling family.
|
|
16
11
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
These helpers exist **only in dev builds** — which is exactly right: the tool is
|
|
35
|
-
dev-only, and the global's absence in prod is the signal to no-op.
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Component attribution**: every finding names the Angular component to fix,
|
|
15
|
+
walking past UI-library components (Material, CDK, Nebular, …) to yours. Uses
|
|
16
|
+
Angular's documented dev debug API (`window.ng`).
|
|
17
|
+
- **In-app provider**: rescans as the app settles; grouped console output and an
|
|
18
|
+
optional on-page overlay. Switch it on and off with the on-page pill or
|
|
19
|
+
Alt+Shift+A; the choice is remembered.
|
|
20
|
+
- **Report mode**: scan many routes headless from the CLI; Markdown, JSON and a
|
|
21
|
+
self-contained HTML report.
|
|
22
|
+
- **CI gating with a baseline**: fail only on *new* issues, so an app with known
|
|
23
|
+
issues can adopt the gate today.
|
|
24
|
+
- **Dark mode**: scan your dark theme too, whether it follows the OS setting, a
|
|
25
|
+
class, an attribute, or custom logic.
|
|
26
|
+
- **Keyboard & Focus Mode**: tab-order visualisation, keyboard findings,
|
|
27
|
+
accessibility-tree preview, and keyboard-trap detection with real Tab presses.
|
|
28
|
+
- **Zero production weight**: a no-op in production; axe-core is never loaded.
|
|
36
29
|
|
|
37
30
|
## Install
|
|
38
31
|
|
|
39
32
|
```bash
|
|
40
33
|
npm i -D @ngbracket/a11y-devtools
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Peer deps: `@angular/core >=18`, `rxjs >=7`.
|
|
44
|
-
|
|
45
|
-
## Usage
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
// app.config.ts (dev configuration)
|
|
49
|
-
import { provideA11yDevtools } from '@ngbracket/a11y-devtools';
|
|
50
|
-
|
|
51
|
-
export const appConfig = {
|
|
52
|
-
providers: [
|
|
53
|
-
// ...your providers
|
|
54
|
-
provideA11yDevtools(),
|
|
55
|
-
],
|
|
56
|
-
};
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
It rescans whenever the app settles (zoneless-aware, via `ApplicationRef.isStable`)
|
|
60
|
-
and logs violations grouped by owning component. Options:
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
provideA11yDevtools({
|
|
64
|
-
root: () => document.querySelector('main')!, // scan scope; default document
|
|
65
|
-
log: true, // grouped console output; default true
|
|
66
|
-
overlay: true, // in-app visual highlights over flagged nodes; default false
|
|
67
|
-
debounceMs: 500, // quiet window after stabilization before scanning
|
|
68
|
-
tags: ['wcag22aa'], // scope the ruleset; default = axe-core's full ruleset
|
|
69
|
-
frameworkPrefixes: ['Nb', 'Mat', 'Cdk', 'Mdc'], // UI primitives to attribute past (default)
|
|
70
|
-
keyboard: true, // also run the keyboard layer (see below); default false
|
|
71
|
-
});
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Framework prefixes.** Attribution walks *past* third-party UI primitives to the app
|
|
75
|
-
component that placed them — a `<button nbButton>` with no name is blamed on your
|
|
76
|
-
`HeaderComponent`, not `NbButtonComponent`. The default list is `Nb`/`Mat`/`Cdk`/`Mdc`;
|
|
77
|
-
override `frameworkPrefixes` to add others (e.g. `['Nb','Mat','Nz','Clr','Ion']` — spread
|
|
78
|
-
`DEFAULT_FRAMEWORK_PREFIXES` to extend), or pass `[]` to attribute to the **immediate**
|
|
79
|
-
owner (useful when auditing a component library's *own* code). The same option is available
|
|
80
|
-
on `scan`, `runA11yScan`, `scanPages`, and the CLI (`--framework-prefixes` / `--no-skip-primitives`).
|
|
81
|
-
|
|
82
|
-
Findings are grouped by owning component, led by a summary line, and each node's
|
|
83
|
-
directives are shown inline:
|
|
84
|
-
|
|
85
|
-
```text
|
|
86
|
-
♿ a11y-devtools: 2 issue(s) across 1 component(s)
|
|
87
|
-
♿ UserCardComponent — 2 issue(s)
|
|
88
|
-
critical · image-alt: Images must have alternative text [via TooltipDirective]
|
|
89
|
-
img
|
|
90
|
-
https://dequeuniversity.com/rules/axe/4.13/image-alt
|
|
91
|
-
serious · color-contrast: Elements must meet minimum contrast
|
|
92
|
-
button.save
|
|
93
|
-
https://dequeuniversity.com/rules/axe/4.13/color-contrast
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
You can also scan on demand:
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
import { runA11yScan, scan } from '@ngbracket/a11y-devtools';
|
|
100
|
-
|
|
101
|
-
const findings = await runA11yScan(); // scan + grouped log
|
|
102
|
-
const raw = await scan(document.body); // findings only
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
`scan()` and `runA11yScan()` also take full axe-core run options as a second
|
|
106
|
-
argument (`scan(root, { runOnly: … })`) for finer control than the provider's
|
|
107
|
-
`tags`.
|
|
108
|
-
|
|
109
|
-
## Report mode (headless, CI-friendly)
|
|
110
|
-
|
|
111
|
-
The provider is for while you're developing a page. **Report mode** turns the same
|
|
112
|
-
engine on a whole running app from the outside: it drives a headless browser over
|
|
113
|
-
your **dev** server, injects the same component-attributed scan, and writes a
|
|
114
|
-
report grouped by owning component — with no change to the app under test. It needs
|
|
115
|
-
a dev build, because that's what publishes `window.ng` for attribution; against a
|
|
116
|
-
production build, attribution falls back to `(unknown component)`.
|
|
117
|
-
|
|
118
|
-
Report mode is opt-in and needs Playwright, an **optional peer** you install
|
|
119
|
-
yourself (so the base package stays weightless):
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
npm i -D playwright
|
|
123
|
-
npx playwright install chromium
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Start your app (`ng serve`), then point the CLI at it:
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
# writes a11y.md and a11y.json
|
|
130
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --route /dashboard --out a11y
|
|
131
|
-
|
|
132
|
-
# …or pick formats: md, json, html (comma-separated), both (= md,json) or all
|
|
133
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --out a11y --format all
|
|
134
|
-
|
|
135
|
-
# CI gate: exit non-zero on any serious/critical finding
|
|
136
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --fail-on serious
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### HTML report
|
|
140
|
-
|
|
141
|
-
`--format html` (or `all`) writes one self-contained `.html` file. It has no
|
|
142
|
-
scripts and makes no external requests, so you can attach it to a CI run, email it,
|
|
143
|
-
or open it offline. It has the same content as the Markdown report, and it's
|
|
144
|
-
accessible itself: landmarks, a sequential heading outline, a real data table,
|
|
145
|
-
severity written as text (not colour alone), and AA contrast in light and dark
|
|
146
|
-
mode. Its own report-mode scan comes back clean.
|
|
147
34
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
By default the headless browser reports a **light** colour-scheme preference, so a
|
|
151
|
-
dark theme is never switched on and its contrast is never checked. Pick the
|
|
152
|
-
scheme(s) to scan with `--color-scheme`:
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
# dark theme driven by prefers-color-scheme (the OS setting)
|
|
156
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --color-scheme both
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
- `light` (default) or `dark` scans once in that scheme. Dark pages are labelled
|
|
160
|
-
`/route (dark)`.
|
|
161
|
-
- `both` scans each route twice. To avoid listing everything twice, the dark page
|
|
162
|
-
shows only the issues that **don't also** appear in light mode (typically contrast
|
|
163
|
-
problems specific to the dark palette).
|
|
164
|
-
|
|
165
|
-
Many apps switch themes with a class or attribute instead of the OS setting. For
|
|
166
|
-
those, tell report mode what to set on `<html>` for the dark pass (either flag
|
|
167
|
-
implies `--color-scheme both`):
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --dark-class dark # Tailwind-style
|
|
171
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --dark-attribute data-bs-theme=dark # Bootstrap
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
For anything else (a theme picker, a setting in localStorage, a class on `<body>`),
|
|
175
|
-
use the programmatic hooks. Both receive the pass's `colorScheme`:
|
|
176
|
-
|
|
177
|
-
```ts
|
|
178
|
-
await scanPages({
|
|
179
|
-
baseUrl: 'http://localhost:4200',
|
|
180
|
-
routes: ['/', '/settings'],
|
|
181
|
-
colorScheme: 'both',
|
|
182
|
-
// once per pass, e.g. pick the theme in a persisted setting
|
|
183
|
-
setup: async (page, { colorScheme }) => {
|
|
184
|
-
await page.evaluate((s) => localStorage.setItem('theme', s), colorScheme);
|
|
185
|
-
},
|
|
186
|
-
// after every route loads, for a theme that doesn't persist between pages
|
|
187
|
-
beforeScan: async (page, { colorScheme }) => {
|
|
188
|
-
if (colorScheme === 'dark') await page.click('button[aria-label="Dark theme"]');
|
|
189
|
-
},
|
|
190
|
-
});
|
|
35
|
+
# for report mode only
|
|
36
|
+
npm i -D playwright && npx playwright install chromium
|
|
191
37
|
```
|
|
192
38
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
An app with a backlog of known issues can't turn on `--fail-on` without every build
|
|
196
|
-
failing. A **baseline** fixes that. Save one run's JSON report, commit it, and
|
|
197
|
-
compare later runs against it:
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
# once: record today's state (commit a11y-baseline.json)
|
|
201
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --route /dashboard \
|
|
202
|
-
--out a11y-baseline --format json
|
|
203
|
-
|
|
204
|
-
# in CI: fail only on findings that aren't in the baseline
|
|
205
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --route /dashboard \
|
|
206
|
-
--baseline a11y-baseline.json --fail-on serious --out a11y --format all
|
|
207
|
-
```
|
|
39
|
+
Needs Angular 18+.
|
|
208
40
|
|
|
209
|
-
|
|
210
|
-
the build, and the report shows what's **new**, **fixed** and **unchanged**.
|
|
211
|
-
- A finding's identity is its route, rule, owning component and element selector.
|
|
212
|
-
Angular's per-build `_ngcontent-…` style hashes are ignored, and so is reworded help
|
|
213
|
-
text after an axe upgrade.
|
|
214
|
-
- A route the baseline never scanned counts as entirely new, so re-record the
|
|
215
|
-
baseline when you add routes. A route that fails to scan isn't reported as "fixed".
|
|
216
|
-
- To ratchet down, re-record the baseline after fixing issues. The JSON from any run
|
|
217
|
-
(including a `--baseline` run) is itself a valid baseline.
|
|
41
|
+
## Quick start
|
|
218
42
|
|
|
219
|
-
|
|
220
|
-
`setup` hook (run once before the routes are scanned):
|
|
43
|
+
While you build:
|
|
221
44
|
|
|
222
45
|
```ts
|
|
223
|
-
|
|
46
|
+
// app.config.ts
|
|
47
|
+
import { provideA11yDevtools } from '@ngbracket/a11y-devtools';
|
|
224
48
|
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
setup: async (page) => {
|
|
229
|
-
await page.goto('http://localhost:4200/login');
|
|
230
|
-
await page.fill('#email', 'demo@example.com');
|
|
231
|
-
await page.click('button[type=submit]');
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
console.log(toMarkdown(report));
|
|
49
|
+
export const appConfig: ApplicationConfig = {
|
|
50
|
+
providers: [provideA11yDevtools({ overlay: true, keyboard: true })],
|
|
51
|
+
};
|
|
235
52
|
```
|
|
236
53
|
|
|
237
|
-
The same pieces are exported for your own pipeline: `toJson`, `toHtml`,
|
|
238
|
-
`parseBaseline` and `diffAgainstBaseline` (pass the diff as the second argument to
|
|
239
|
-
`toMarkdown` / `toJson` / `toHtml`).
|
|
240
|
-
|
|
241
|
-
The report leads with a summary of **distinct rules vs. raw node-instances** (a
|
|
242
|
-
"54" is usually one rule firing dozens of times), then lists findings under each
|
|
243
|
-
owning component. When a flagged control is itself a third-party UI primitive
|
|
244
|
-
(e.g. `<button nbButton>`), attribution walks past the primitive to the app
|
|
245
|
-
component that placed it and notes the primitive as `(via …)`.
|
|
246
|
-
|
|
247
|
-
## Keyboard & Focus Mode (the ~2/3 axe can't test)
|
|
248
|
-
|
|
249
|
-
axe covers the machine-testable third of WCAG. **Keyboard & Focus Mode** starts on
|
|
250
|
-
the rest — keyboard operability — still naming the component that owns each issue.
|
|
251
|
-
Turn it on with `keyboard: true` (provider / `runA11yScan` / `scan` / `scanPages`)
|
|
252
|
-
or `--keyboard` on the CLI.
|
|
253
|
-
|
|
254
54
|

|
|
259
59
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
- **Tab-order visualisation** (overlay): numbered badges at each tab stop and a
|
|
263
|
-
connector path showing the order focus actually moves. A positive-`tabindex` stop
|
|
264
|
-
is coloured as a warning, because it hijacks the natural order.
|
|
265
|
-
- **Keyboard findings**, grouped and reported exactly like the axe violations:
|
|
266
|
-
- `ngbr/unreachable-control` — an interactive element (an ARIA role, or a runtime
|
|
267
|
-
`click` listener) that isn't a native control and has no `tabindex >= 0`, so the
|
|
268
|
-
keyboard can't reach it.
|
|
269
|
-
- `ngbr/click-without-key` — a focusable element with a `(click)` handler but no
|
|
270
|
-
keyboard handler, so Enter/Space may not activate it. This is read from
|
|
271
|
-
`window.ng.getListeners` — a **runtime** signal a static template lint can't see
|
|
272
|
-
(e.g. a handler added via `hostDirectives`).
|
|
273
|
-
- `ngbr/tab-order-mismatch` — the tab path jumps against the visual reading order
|
|
274
|
-
(needs real layout, so it fires in report-mode / a real browser).
|
|
275
|
-
- `ngbr/modal-focus-not-contained` — an open `aria-modal="true"` whose focus isn't
|
|
276
|
-
contained: tabbable elements outside it are still reachable, so a keyboard user
|
|
277
|
-
can Tab out to the page behind. (A modal that correctly marks the background
|
|
278
|
-
`inert` is not flagged, since those elements are no longer tabbable.)
|
|
279
|
-
|
|
280
|
-
```bash
|
|
281
|
-
# include the keyboard layer in a report-mode run
|
|
282
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --keyboard
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
**Honesty guardrail:** `click-without-key`, `tab-order-mismatch`,
|
|
286
|
-
`modal-focus-not-contained` and `focus-trap` are *heuristics*. They're labelled
|
|
287
|
-
"verify manually" and never reported as confirmed failures.
|
|
288
|
-
|
|
289
|
-
### Keyboard traps (report-mode, M3)
|
|
290
|
-
|
|
291
|
-
A keyboard trap is focus you can Tab *into* but never Tab *out of*
|
|
292
|
-
([WCAG 2.1.2](https://www.w3.org/WAI/WCAG22/Understanding/no-keyboard-trap.html)).
|
|
293
|
-
You can't find one by reading the DOM. Script makes the trap, by intercepting Tab or
|
|
294
|
-
re-focusing on blur, and synthetic key events don't move focus in a browser. So
|
|
295
|
-
report-mode presses the **real** Tab key through each route:
|
|
60
|
+
In CI, against a running `ng serve`:
|
|
296
61
|
|
|
297
62
|
```bash
|
|
298
|
-
npx ngbr-a11y-report --base http://localhost:4200 --route / --
|
|
63
|
+
npx ngbr-a11y-report --base http://localhost:4200 --route / --route /settings \
|
|
64
|
+
--keyboard --baseline a11y-baseline.json --fail-on serious --out a11y --format all
|
|
299
65
|
```
|
|
300
66
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
- Focus cycling inside an open `aria-modal` / `<dialog>` is containment working,
|
|
308
|
-
so it isn't reported. Consecutive focus on an `<iframe>` (Tab moving inside the
|
|
309
|
-
frame) isn't read as a trap either.
|
|
67
|
+
Next steps, in the docs:
|
|
68
|
+
[Your first scan](https://ngbracket.com/tools/a11y-devtools/docs/first-scan) ·
|
|
69
|
+
[Report mode](https://ngbracket.com/tools/a11y-devtools/docs/report-mode) ·
|
|
70
|
+
[CI gating with a baseline](https://ngbracket.com/tools/a11y-devtools/docs/ci-baseline) ·
|
|
71
|
+
[CLI reference](https://ngbracket.com/tools/a11y-devtools/docs/cli) ·
|
|
72
|
+
[Findings & rules](https://ngbracket.com/tools/a11y-devtools/docs/findings)
|
|
310
73
|
|
|
311
|
-
|
|
312
|
-
that *changes the page*. Pressing Tab can fire focus handlers and open menus, so
|
|
313
|
-
it runs after the scan. A widget that deliberately keeps Tab, like a code editor,
|
|
314
|
-
is fine if it tells users how to leave (Escape, for example). That's why the finding
|
|
315
|
-
says "verify manually".
|
|
74
|
+
## What it can't do
|
|
316
75
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
axe-core's own accessible-name commons (one accname source, shared with the scan),
|
|
323
|
-
and a missing accessible name is flagged in warning colour.
|
|
324
|
-
|
|
325
|
-
> **Accessibility-tree preview — computed approximation.** This is a *computed*
|
|
326
|
-
> name/role/state, an approximation of what assistive tech announces — **not** what
|
|
327
|
-
> any one screen reader says. Real output varies by screen reader (NVDA / JAWS /
|
|
328
|
-
> VoiceOver), browse vs. focus mode, verbosity, and browser. Use it to catch
|
|
329
|
-
> missing names and wrong roles fast; confirm the announcement with a real SR.
|
|
330
|
-
|
|
331
|
-
The same computation is available programmatically via `describeElement(el)`
|
|
332
|
-
(async — it loads axe on demand), plus the pure `ariaStates(el)` and
|
|
333
|
-
`accessibleDescription(el)` helpers.
|
|
334
|
-
|
|
335
|
-
## What it checks (and what it can't)
|
|
336
|
-
|
|
337
|
-
Under the hood this is [axe-core](https://github.com/dequelabs/axe-core) — the
|
|
338
|
-
scan runs axe's rules and enriches each violation with the owning component. By
|
|
339
|
-
default it runs axe-core's full ruleset: the **machine-testable** rules across
|
|
340
|
-
**WCAG 2.0, 2.1 and 2.2, Levels A & AA**, plus axe's *best-practice* rules. Scope
|
|
341
|
-
it to a single conformance target with `tags` (e.g. `['wcag22aa']`) or
|
|
342
|
-
`['wcag21aa', 'best-practice']`.
|
|
343
|
-
|
|
344
|
-
Automated checks only cover the part of WCAG a machine can test — on the order of
|
|
345
|
-
a third of the success criteria. Many WCAG 2.2 additions have **no automated rule
|
|
346
|
-
at all** (target size 2.5.8, dragging 2.5.7, consistent help, redundant entry,
|
|
347
|
-
accessible authentication), so a clean run is necessary, not sufficient — the rest
|
|
348
|
-
needs keyboard, screen-reader and human testing. (WCAG 3.0 is still an early W3C
|
|
349
|
-
draft with a different, non-final model; there's nothing to test against yet.)
|
|
350
|
-
|
|
351
|
-
## Production weight
|
|
352
|
-
|
|
353
|
-
In production `provideA11yDevtools()` is a **no-op** and axe-core is never loaded.
|
|
354
|
-
axe-core is a **dynamic import**, so it lands in a lazy chunk that prod never
|
|
355
|
-
fetches, and the package is `sideEffects: false` so an unused import tree-shakes
|
|
356
|
-
away entirely. For a hard guarantee, include the provider only in your dev
|
|
357
|
-
bootstrap config (e.g. behind `isDevMode()`).
|
|
358
|
-
|
|
359
|
-
This is **enforced in CI**: `src/testing/prod-weight.spec.ts` bundles the entry
|
|
360
|
-
with esbuild and walks the module graph — axe-core must be reachable *only*
|
|
361
|
-
through a dynamic import, never a static one. Turning `import('axe-core')` into a
|
|
362
|
-
static import (or adding a top-level side effect) fails the build.
|
|
76
|
+
Automated checks cover part of WCAG, so a clean run is necessary, not sufficient:
|
|
77
|
+
keyboard, screen-reader and human testing cover the rest. The keyboard findings are
|
|
78
|
+
heuristics, labelled "verify manually". It helps you build toward supporting WCAG
|
|
79
|
+
2.2 AA; it doesn't certify conformance. See
|
|
80
|
+
[What it checks (and what it can't)](https://ngbracket.com/tools/a11y-devtools/docs/coverage).
|
|
363
81
|
|
|
364
82
|
## Develop
|
|
365
83
|
|
|
366
84
|
```bash
|
|
367
85
|
npm install --legacy-peer-deps
|
|
86
|
+
npm run build # tsc -> dist/ (ESM + .d.ts) + the in-page bundle
|
|
368
87
|
npm test # vitest + jsdom + Angular TestBed (real axe); the real-browser
|
|
369
88
|
# E2E spec runs after a build, once `npx playwright install chromium`
|
|
370
|
-
npm run build # tsc -> dist/ (ESM + .d.ts)
|
|
371
89
|
```
|
|
372
90
|
|
|
91
|
+
CI also runs a production-weight guard: a bundle-graph test that fails if axe-core
|
|
92
|
+
ever becomes reachable through a static import.
|
|
93
|
+
|
|
373
94
|
## Roadmap
|
|
374
95
|
|
|
375
96
|
### Planned
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export { runA11yScan, type RunOptions } from './runner.js';
|
|
|
3
3
|
export { scan, type A11yFinding, type Impact, type ScanOptions } from './scan.js';
|
|
4
4
|
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
|
-
export { tabSequence, isTabbable, isNativelyFocusable, resolvedTabIndex, visualOrderJumps, type TabStop, type TabSequenceOptions, } from './keyboard/tab-sequence.js';
|
|
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
8
|
export { findUncontainedModals, type UncontainedModal } from './keyboard/focus-trap.js';
|
|
9
9
|
export { createFocusWalkProbe, detectTabTrap, type FocusObservation, type FocusWalkProbe, type TabWalkVerdict, } from './keyboard/focus-walk.js';
|
|
10
10
|
export { describeElement, accessibleDescription, ariaStates, type AxDescription, } from './keyboard/accname.js';
|
|
11
11
|
export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, type A11yOverlay, type OverlayOptions, type AxPanelData, } from './overlay.js';
|
|
12
|
+
export { createTogglePill, parseShortcut, matchesShortcut, formatShortcut, readStoredEnabled, writeStoredEnabled, DEFAULT_TOGGLE_SHORTCUT, TOGGLE_STORAGE_KEY, type PillPosition, type Shortcut, type TogglePill, type TogglePillOptions, } from './toggle.js';
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,10 @@ export { runA11yScan } from './runner.js';
|
|
|
3
3
|
export { scan } from './scan.js';
|
|
4
4
|
export { logFindings } from './report.js';
|
|
5
5
|
export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, resolveListenerEvents, DEFAULT_FRAMEWORK_PREFIXES, ngDebug, } from './attribution.js';
|
|
6
|
-
export { tabSequence, isTabbable, isNativelyFocusable, resolvedTabIndex, visualOrderJumps, } from './keyboard/tab-sequence.js';
|
|
6
|
+
export { tabSequence, hasFocusableDescendant, isTabbable, isNativelyFocusable, resolvedTabIndex, visualOrderJumps, } from './keyboard/tab-sequence.js';
|
|
7
7
|
export { scanKeyboard } from './keyboard/keyboard-scan.js';
|
|
8
8
|
export { findUncontainedModals } from './keyboard/focus-trap.js';
|
|
9
9
|
export { createFocusWalkProbe, detectTabTrap, } from './keyboard/focus-walk.js';
|
|
10
10
|
export { describeElement, accessibleDescription, ariaStates, } from './keyboard/accname.js';
|
|
11
11
|
export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, } from './overlay.js';
|
|
12
|
+
export { createTogglePill, parseShortcut, matchesShortcut, formatShortcut, readStoredEnabled, writeStoredEnabled, DEFAULT_TOGGLE_SHORTCUT, TOGGLE_STORAGE_KEY, } from './toggle.js';
|