@ngbracket/a11y-devtools 0.5.0 → 0.7.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 +46 -0
- package/README.md +59 -4
- package/bin/ngbr-a11y-report.mjs +5 -0
- package/dist/attribution.d.ts +22 -0
- package/dist/attribution.js +26 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +4 -1
- package/dist/inpage.global.js +378 -8
- package/dist/keyboard/accname.d.ts +42 -0
- package/dist/keyboard/accname.js +131 -0
- package/dist/keyboard/keyboard-scan.d.ts +14 -0
- package/dist/keyboard/keyboard-scan.js +117 -0
- package/dist/keyboard/tab-sequence.d.ts +58 -0
- package/dist/keyboard/tab-sequence.js +178 -0
- package/dist/overlay.d.ts +22 -0
- package/dist/overlay.js +157 -1
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +36 -4
- package/dist/report/headless.d.ts +7 -0
- package/dist/report/headless.js +2 -2
- package/dist/runner.d.ts +6 -0
- package/dist/runner.js +1 -0
- package/dist/scan.d.ts +7 -0
- package/dist/scan.js +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,52 @@
|
|
|
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.7.0
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- **Keyboard & Focus Mode — M2: the accessibility-tree preview.** With
|
|
11
|
+
`keyboard: true` **and** `overlay: true`, a panel now follows focus: as you Tab,
|
|
12
|
+
it shows the focused control's computed **role, accessible name, description, and
|
|
13
|
+
ARIA states**, attributed to the owning component.
|
|
14
|
+
- Name and role are computed by **axe-core's own accname commons** (one accname
|
|
15
|
+
source, not a second home-grown one). axe stays behind a dynamic import, so the
|
|
16
|
+
prod-weight guarantee is unchanged.
|
|
17
|
+
- **Honesty guardrail:** the panel is headed *"Accessibility-tree preview —
|
|
18
|
+
computed approximation"* and never branded as any specific screen reader's
|
|
19
|
+
output. A missing accessible name is flagged in warning colour.
|
|
20
|
+
- New public API: `describeElement` (async, axe-backed), `accessibleDescription`,
|
|
21
|
+
`ariaStates`, and the `AxDescription` / `AxPanelData` types; the overlay gains
|
|
22
|
+
`renderAxPanel`.
|
|
23
|
+
|
|
24
|
+
## 0.6.0
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **Keyboard & Focus Mode — M1: the keyboard layer.** The first checks for the
|
|
29
|
+
~2/3 of accessibility axe can't test — keyboard operability — attributed to the
|
|
30
|
+
owning component like everything else. Opt in with `keyboard: true` (provider /
|
|
31
|
+
`runA11yScan` / `scan` / `scanPages`) or `--keyboard` on the CLI.
|
|
32
|
+
- **Tab-order visualisation** (overlay): numbered badges at each tab stop plus a
|
|
33
|
+
connector path showing the order focus actually moves; a positive-`tabindex`
|
|
34
|
+
stop is flagged as a warning because it hijacks the natural order.
|
|
35
|
+
- **Keyboard findings** (`ngbr/*` rule ids, grouped and reported like axe
|
|
36
|
+
violations):
|
|
37
|
+
- `ngbr/unreachable-control` (serious) — an interactive element (ARIA role or a
|
|
38
|
+
runtime `click` listener) that isn't a native control and has no
|
|
39
|
+
`tabindex >= 0`, so it can't be reached by keyboard.
|
|
40
|
+
- `ngbr/click-without-key` (moderate, heuristic) — a focusable element with a
|
|
41
|
+
`(click)` handler but no keyboard handler, so Enter/Space may not activate it.
|
|
42
|
+
Read from `window.ng.getListeners`, a **runtime** signal a static template
|
|
43
|
+
lint can't see (e.g. a listener added via `hostDirectives`).
|
|
44
|
+
- `ngbr/tab-order-mismatch` (moderate, heuristic) — the tab path jumps against
|
|
45
|
+
the visual reading order. Needs real layout (report-mode / a real browser).
|
|
46
|
+
- New public API: `tabSequence`, `scanKeyboard`, `isTabbable`,
|
|
47
|
+
`isNativelyFocusable`, `resolvedTabIndex`, `visualOrderJumps`,
|
|
48
|
+
`resolveListenerEvents`, and the `TabStop` / `NgListener` types.
|
|
49
|
+
- **Honesty guardrail:** the heuristic findings are labelled "verify manually",
|
|
50
|
+
never reported as confirmed failures.
|
|
51
|
+
|
|
6
52
|
## 0.5.0
|
|
7
53
|
|
|
8
54
|
### Added
|
package/README.md
CHANGED
|
@@ -18,7 +18,10 @@ Part of the `@ngbracket` Angular tooling family.
|
|
|
18
18
|
|
|
19
19
|
Ships attribution — component **and** directive-level — + axe scan + grouped
|
|
20
20
|
console reporter (with a summary line) + the dev-only provider + the visual in-app
|
|
21
|
-
overlay (severity-coloured highlights, click-to-scroll)
|
|
21
|
+
overlay (severity-coloured highlights, click-to-scroll) + headless report mode +
|
|
22
|
+
**Keyboard & Focus Mode M1 + M2** — tab-order visualisation, keyboard-reachability
|
|
23
|
+
findings, and a focus-follow accessibility-tree preview (the part of accessibility
|
|
24
|
+
axe can't test).
|
|
22
25
|
|
|
23
26
|
## How the attribution works
|
|
24
27
|
|
|
@@ -63,6 +66,7 @@ provideA11yDevtools({
|
|
|
63
66
|
debounceMs: 500, // quiet window after stabilization before scanning
|
|
64
67
|
tags: ['wcag22aa'], // scope the ruleset; default = axe-core's full ruleset
|
|
65
68
|
frameworkPrefixes: ['Nb', 'Mat', 'Cdk', 'Mdc'], // UI primitives to attribute past (default)
|
|
69
|
+
keyboard: true, // also run the keyboard layer (see below); default false
|
|
66
70
|
});
|
|
67
71
|
```
|
|
68
72
|
|
|
@@ -152,6 +156,53 @@ owning component. When a flagged control is itself a third-party UI primitive
|
|
|
152
156
|
(e.g. `<button nbButton>`), attribution walks past the primitive to the app
|
|
153
157
|
component that placed it and notes the primitive as `(via …)`.
|
|
154
158
|
|
|
159
|
+
## Keyboard & Focus Mode (the ~2/3 axe can't test)
|
|
160
|
+
|
|
161
|
+
axe covers the machine-testable third of WCAG. **Keyboard & Focus Mode** starts on
|
|
162
|
+
the rest — keyboard operability — still naming the component that owns each issue.
|
|
163
|
+
Turn it on with `keyboard: true` (provider / `runA11yScan` / `scan` / `scanPages`)
|
|
164
|
+
or `--keyboard` on the CLI. It adds:
|
|
165
|
+
|
|
166
|
+
- **Tab-order visualisation** (overlay): numbered badges at each tab stop and a
|
|
167
|
+
connector path showing the order focus actually moves. A positive-`tabindex` stop
|
|
168
|
+
is coloured as a warning, because it hijacks the natural order.
|
|
169
|
+
- **Keyboard findings**, grouped and reported exactly like the axe violations:
|
|
170
|
+
- `ngbr/unreachable-control` — an interactive element (an ARIA role, or a runtime
|
|
171
|
+
`click` listener) that isn't a native control and has no `tabindex >= 0`, so the
|
|
172
|
+
keyboard can't reach it.
|
|
173
|
+
- `ngbr/click-without-key` — a focusable element with a `(click)` handler but no
|
|
174
|
+
keyboard handler, so Enter/Space may not activate it. This is read from
|
|
175
|
+
`window.ng.getListeners` — a **runtime** signal a static template lint can't see
|
|
176
|
+
(e.g. a handler added via `hostDirectives`).
|
|
177
|
+
- `ngbr/tab-order-mismatch` — the tab path jumps against the visual reading order
|
|
178
|
+
(needs real layout, so it fires in report-mode / a real browser).
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# include the keyboard layer in a report-mode run
|
|
182
|
+
npx ngbr-a11y-report --base http://localhost:4200 --route / --keyboard
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Honesty guardrail:** `click-without-key` and `tab-order-mismatch` are
|
|
186
|
+
*heuristics* — labelled "verify manually", never reported as confirmed failures.
|
|
187
|
+
|
|
188
|
+
### Accessibility-tree preview (M2)
|
|
189
|
+
|
|
190
|
+
With `keyboard: true` **and** `overlay: true`, a panel follows focus: as you Tab, it
|
|
191
|
+
shows the focused control's computed **role, accessible name, description, and ARIA
|
|
192
|
+
states** — attributed to its owning component. The name and role come from
|
|
193
|
+
axe-core's own accessible-name commons (one accname source, shared with the scan),
|
|
194
|
+
and a missing accessible name is flagged in warning colour.
|
|
195
|
+
|
|
196
|
+
> **Accessibility-tree preview — computed approximation.** This is a *computed*
|
|
197
|
+
> name/role/state, an approximation of what assistive tech announces — **not** what
|
|
198
|
+
> any one screen reader says. Real output varies by screen reader (NVDA / JAWS /
|
|
199
|
+
> VoiceOver), browse vs. focus mode, verbosity, and browser. Use it to catch
|
|
200
|
+
> missing names and wrong roles fast; confirm the announcement with a real SR.
|
|
201
|
+
|
|
202
|
+
The same computation is available programmatically via `describeElement(el)`
|
|
203
|
+
(async — it loads axe on demand), plus the pure `ariaStates(el)` and
|
|
204
|
+
`accessibleDescription(el)` helpers.
|
|
205
|
+
|
|
155
206
|
## What it checks (and what it can't)
|
|
156
207
|
|
|
157
208
|
Under the hood this is [axe-core](https://github.com/dequelabs/axe-core) — the
|
|
@@ -191,11 +242,15 @@ npm run build # tsc -> dist/ (ESM + .d.ts)
|
|
|
191
242
|
|
|
192
243
|
## Roadmap
|
|
193
244
|
|
|
194
|
-
-
|
|
245
|
+
- Keyboard & Focus Mode **M3** — focus-trap *candidate* detection.
|
|
246
|
+
- Headless "linear walkthrough" — the tab sequence as an SR-ish reading list per
|
|
247
|
+
route in report-mode (M2's preview is currently overlay-only).
|
|
195
248
|
- HTML report + baseline/diff mode for CI.
|
|
196
249
|
- Per-component filtering and a violation-count badge.
|
|
197
250
|
|
|
198
251
|
Done: component attribution (nearest app-owned, walking past UI primitives) ·
|
|
199
|
-
directive / `hostDirectives` attribution ·
|
|
200
|
-
dev-only provider · in-app overlay · headless
|
|
252
|
+
directive / `hostDirectives` attribution · configurable framework prefixes · axe
|
|
253
|
+
scan · grouped console reporter · dev-only provider · in-app overlay · headless
|
|
254
|
+
report mode (CLI + `./report`) · **Keyboard & Focus Mode M1** (tab-order viz +
|
|
255
|
+
keyboard-reachability findings) · **M2** (focus-follow accessibility-tree preview) ·
|
|
201
256
|
CI prod-weight guard.
|
package/bin/ngbr-a11y-report.mjs
CHANGED
|
@@ -23,6 +23,9 @@ Options:
|
|
|
23
23
|
--no-skip-primitives
|
|
24
24
|
Attribute to the immediate owner (skip nothing) — use when
|
|
25
25
|
scanning a component library's own code
|
|
26
|
+
--keyboard Also run the keyboard layer: heuristic ngbr/* findings for
|
|
27
|
+
keyboard-unreachable controls, click-without-keyboard
|
|
28
|
+
handlers, and visual-vs-tab-order mismatches
|
|
26
29
|
--headed Launch a visible browser (debugging)
|
|
27
30
|
-h, --help Show this help
|
|
28
31
|
`;
|
|
@@ -46,6 +49,7 @@ function parseArgs(argv) {
|
|
|
46
49
|
opts.frameworkPrefixes = next().split(',').map((s) => s.trim()).filter(Boolean);
|
|
47
50
|
break;
|
|
48
51
|
case '--no-skip-primitives': opts.frameworkPrefixes = []; break;
|
|
52
|
+
case '--keyboard': opts.keyboard = true; break;
|
|
49
53
|
case '--headed': opts.headed = true; break;
|
|
50
54
|
case '-h': case '--help': opts.help = true; break;
|
|
51
55
|
default: console.error(`Unknown argument: ${arg}\n`); opts.help = true;
|
|
@@ -68,6 +72,7 @@ const report = await scanPages({
|
|
|
68
72
|
waitMs: opts.wait,
|
|
69
73
|
headed: opts.headed,
|
|
70
74
|
frameworkPrefixes: opts.frameworkPrefixes,
|
|
75
|
+
keyboard: opts.keyboard,
|
|
71
76
|
});
|
|
72
77
|
|
|
73
78
|
const allFindings = report.pages.flatMap((p) => p.findings);
|
package/dist/attribution.d.ts
CHANGED
|
@@ -14,7 +14,29 @@ export interface NgDebugGlobal {
|
|
|
14
14
|
getComponent(element: Element): unknown;
|
|
15
15
|
getOwningComponent(element: Element | object): unknown;
|
|
16
16
|
getDirectives(element: Element | object): unknown[];
|
|
17
|
+
/**
|
|
18
|
+
* Listeners Angular bound to a node — template `(event)` bindings plus
|
|
19
|
+
* `@HostListener`s. Present on the dev global alongside the other helpers; the
|
|
20
|
+
* keyboard scan uses it to see, at runtime, which elements have a `click`
|
|
21
|
+
* handler but no keyboard handler — a case a static template lint can't catch
|
|
22
|
+
* (e.g. a listener added by a directive via `hostDirectives`).
|
|
23
|
+
*/
|
|
24
|
+
getListeners?(element: Element): NgListener[];
|
|
17
25
|
}
|
|
26
|
+
/** Shape of an entry returned by `window.ng.getListeners`. */
|
|
27
|
+
export interface NgListener {
|
|
28
|
+
name: string;
|
|
29
|
+
type?: 'dom' | 'output';
|
|
30
|
+
callback?: unknown;
|
|
31
|
+
useCapture?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The DOM event names Angular has a listener bound for on `node` (template
|
|
35
|
+
* `(event)` bindings and `@HostListener`s), lowercased and de-duplicated. Empty
|
|
36
|
+
* when the debug global is absent (prod) or the node has none. Output/`@Output`
|
|
37
|
+
* emitters are excluded — only real DOM events matter for keyboard operability.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveListenerEvents(node: Element): string[];
|
|
18
40
|
export declare function ngDebug(): NgDebugGlobal | undefined;
|
|
19
41
|
/**
|
|
20
42
|
* Default component-name prefixes treated as third-party UI primitives (Nebular
|
package/dist/attribution.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DOM event names Angular has a listener bound for on `node` (template
|
|
3
|
+
* `(event)` bindings and `@HostListener`s), lowercased and de-duplicated. Empty
|
|
4
|
+
* when the debug global is absent (prod) or the node has none. Output/`@Output`
|
|
5
|
+
* emitters are excluded — only real DOM events matter for keyboard operability.
|
|
6
|
+
*/
|
|
7
|
+
export function resolveListenerEvents(node) {
|
|
8
|
+
const ng = ngDebug();
|
|
9
|
+
if (typeof ng?.getListeners !== 'function')
|
|
10
|
+
return [];
|
|
11
|
+
let listeners;
|
|
12
|
+
try {
|
|
13
|
+
listeners = ng.getListeners(node) ?? [];
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return []; // node isn't part of a live view
|
|
17
|
+
}
|
|
18
|
+
const events = new Set();
|
|
19
|
+
for (const listener of listeners) {
|
|
20
|
+
if (listener?.type === 'output')
|
|
21
|
+
continue;
|
|
22
|
+
if (typeof listener?.name === 'string')
|
|
23
|
+
events.add(listener.name.toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
return [...events];
|
|
26
|
+
}
|
|
1
27
|
export function ngDebug() {
|
|
2
28
|
return globalThis.ng;
|
|
3
29
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,8 @@ export { provideA11yDevtools, type A11yDevtoolsOptions } from './provider.js';
|
|
|
2
2
|
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
|
-
export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, ngDebug, type NgDebugGlobal, } from './attribution.js';
|
|
6
|
-
export {
|
|
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';
|
|
7
|
+
export { scanKeyboard, type KeyboardScanOptions } from './keyboard/keyboard-scan.js';
|
|
8
|
+
export { describeElement, accessibleDescription, ariaStates, type AxDescription, } from './keyboard/accname.js';
|
|
9
|
+
export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, type A11yOverlay, type OverlayOptions, type AxPanelData, } from './overlay.js';
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,8 @@ export { provideA11yDevtools } from './provider.js';
|
|
|
2
2
|
export { runA11yScan } from './runner.js';
|
|
3
3
|
export { scan } from './scan.js';
|
|
4
4
|
export { logFindings } from './report.js';
|
|
5
|
-
export { resolveOwningComponentName, resolveComponentPath, appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, ngDebug, } from './attribution.js';
|
|
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';
|
|
7
|
+
export { scanKeyboard } from './keyboard/keyboard-scan.js';
|
|
8
|
+
export { describeElement, accessibleDescription, ariaStates, } from './keyboard/accname.js';
|
|
6
9
|
export { createOverlay, OVERLAY_ATTR, OVERLAY_EXCLUDE_SELECTOR, } from './overlay.js';
|