@ngbracket/a11y-devtools 0.15.8 → 0.17.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 +82 -0
- package/dist/attribution.d.ts +9 -0
- package/dist/attribution.js +11 -3
- package/dist/inpage.global.js +322 -7
- package/dist/keyboard/drag-drop.d.ts +45 -0
- package/dist/keyboard/drag-drop.js +95 -0
- package/dist/keyboard/focus-walk.js +4 -1
- package/dist/keyboard/hover-content.d.ts +14 -0
- package/dist/keyboard/hover-content.js +161 -0
- package/dist/keyboard/keyboard-scan.d.ts +12 -3
- package/dist/keyboard/keyboard-scan.js +202 -8
- package/dist/keyboard/tab-sequence.d.ts +4 -2
- package/dist/keyboard/tab-sequence.js +39 -8
- package/dist/overlay.js +1 -1
- package/dist/provider.d.ts +3 -1
- package/dist/report/acr.js +2 -0
- package/dist/report/headless.d.ts +3 -2
- package/dist/runner.d.ts +3 -2
- package/dist/scan.d.ts +6 -0
- package/package.json +14 -10
|
@@ -16,8 +16,8 @@ import { blockingModalDialog } from '../top-layer.js';
|
|
|
16
16
|
/**
|
|
17
17
|
* A focus-trap sentinel: an empty, script-driven tab stop that sends focus back
|
|
18
18
|
* into the modal when reached — Angular CDK / Material's `cdk-focus-trap-anchor`
|
|
19
|
-
* (`tabindex="0"`, `aria-hidden="true"`),
|
|
20
|
-
* focus-lock pattern). No text and no child elements, so it isn't real content.
|
|
19
|
+
* (`tabindex="0"`, `aria-hidden="true"`), PrimeNG's `p-hidden-focusable` span,
|
|
20
|
+
* or a `data-focus-guard` element (the focus-lock pattern). No text and no child elements, so it isn't real content.
|
|
21
21
|
*/
|
|
22
22
|
export function isFocusSentinel(el) {
|
|
23
23
|
if (el.childElementCount > 0 || (el.textContent ?? '').trim() !== '')
|
|
@@ -25,14 +25,41 @@ export function isFocusSentinel(el) {
|
|
|
25
25
|
return el.getAttribute('aria-hidden') === 'true' || el.hasAttribute('data-focus-guard');
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
28
|
+
* Dialogs from libraries that trap Tab with a script and add no sentinels:
|
|
29
|
+
* ng-bootstrap's modal and offcanvas (`ngbFocusTrap`). They're recognised by
|
|
30
|
+
* element name, which is there in production builds too.
|
|
31
|
+
*/
|
|
32
|
+
const SCRIPT_TRAP_SELECTOR = 'ngb-modal-window, ngb-offcanvas-panel';
|
|
33
|
+
/**
|
|
34
|
+
* Elements that may hold a JS focus trap: any `aria-modal`, any dialog role, the
|
|
35
|
+
* Angular CDK / Material dialog containers, and {@link SCRIPT_TRAP_SELECTOR}.
|
|
36
|
+
* Material 22 opens `mat-dialog` with `aria-modal="false"` (it hides the page
|
|
37
|
+
* with `aria-hidden` instead), so `aria-modal="true"` alone misses every default
|
|
38
|
+
* Material dialog.
|
|
39
|
+
*/
|
|
40
|
+
const TRAP_CANDIDATE_SELECTOR = [
|
|
41
|
+
'[aria-modal="true"]',
|
|
42
|
+
'[role="dialog"]',
|
|
43
|
+
'[role="alertdialog"]',
|
|
44
|
+
'mat-dialog-container',
|
|
45
|
+
'.cdk-dialog-container',
|
|
46
|
+
SCRIPT_TRAP_SELECTOR,
|
|
47
|
+
].join(', ');
|
|
48
|
+
/**
|
|
49
|
+
* The open dialog whose focus a JS trap keeps in, or null. Its stops must be one
|
|
50
|
+
* unbroken run in `order`, and one of these holds:
|
|
51
|
+
* - a sentinel sits directly before and after the run, outside the dialog
|
|
52
|
+
* (Angular CDK / Material: the anchors are the dialog container's siblings);
|
|
53
|
+
* - the run starts and ends with a sentinel inside the dialog (PrimeNG's
|
|
54
|
+
* `pFocusTrap` prepends and appends hidden spans; ngx-bootstrap's
|
|
55
|
+
* `modal-container` holds its CDK-style anchors around `.modal-dialog`);
|
|
56
|
+
* - the dialog is one of {@link SCRIPT_TRAP_SELECTOR}.
|
|
57
|
+
* The browser can reach those sentinels, but the trap sends focus from them back
|
|
58
|
+
* into the dialog. Checked with real Tab presses on a CDK dialog: from the last
|
|
32
59
|
* control, Tab wraps to the first. With several, the last is the topmost.
|
|
33
60
|
*/
|
|
34
61
|
function sentinelTrappedModal(root, order) {
|
|
35
|
-
const modals = [...root.querySelectorAll(
|
|
62
|
+
const modals = [...root.querySelectorAll(TRAP_CANDIDATE_SELECTOR)].reverse();
|
|
36
63
|
for (const modal of modals) {
|
|
37
64
|
const inside = order.map((el) => modal.contains(el));
|
|
38
65
|
const first = inside.indexOf(true);
|
|
@@ -43,6 +70,10 @@ function sentinelTrappedModal(root, order) {
|
|
|
43
70
|
const after = order[last + 1];
|
|
44
71
|
if (before && after && isFocusSentinel(before) && isFocusSentinel(after))
|
|
45
72
|
return modal;
|
|
73
|
+
if (last > first && isFocusSentinel(order[first]) && isFocusSentinel(order[last]))
|
|
74
|
+
return modal;
|
|
75
|
+
if (modal.matches(SCRIPT_TRAP_SELECTOR))
|
|
76
|
+
return modal;
|
|
46
77
|
}
|
|
47
78
|
return null;
|
|
48
79
|
}
|
|
@@ -122,7 +153,7 @@ export function resolvedTabIndex(element) {
|
|
|
122
153
|
return Number.isNaN(parsed) ? nativeTabIndex(element) : parsed;
|
|
123
154
|
}
|
|
124
155
|
/** True when `element` (or an ancestor) is disabled via a control or `<fieldset disabled>`. */
|
|
125
|
-
function isDisabled(element) {
|
|
156
|
+
export function isDisabled(element) {
|
|
126
157
|
if ('disabled' in element && element.disabled)
|
|
127
158
|
return true;
|
|
128
159
|
// A disabled fieldset disables its controls (except those inside its first legend).
|
package/dist/overlay.js
CHANGED
|
@@ -190,7 +190,7 @@ export function createOverlay(options = {}) {
|
|
|
190
190
|
function render(findings) {
|
|
191
191
|
clear();
|
|
192
192
|
for (const finding of findings) {
|
|
193
|
-
const target = resolveTarget(doc, finding.target);
|
|
193
|
+
const target = resolveTarget(doc, finding.locator ?? finding.target);
|
|
194
194
|
if (!target)
|
|
195
195
|
continue; // node gone since the scan (e.g. re-rendered)
|
|
196
196
|
const box = buildBox(doc, finding);
|
package/dist/provider.d.ts
CHANGED
|
@@ -31,7 +31,9 @@ export interface A11yDevtoolsOptions {
|
|
|
31
31
|
/**
|
|
32
32
|
* Turn on the **keyboard layer** — the ~2/3 of accessibility axe can't test.
|
|
33
33
|
* Adds heuristic `ngbr/*` findings (keyboard-unreachable controls,
|
|
34
|
-
* click-without-keyboard handlers,
|
|
34
|
+
* click-without-keyboard handlers, hover-only content, drag and drop with no
|
|
35
|
+
* keyboard way, tab-order mismatches)
|
|
36
|
+
* to the report, and,
|
|
35
37
|
* when `overlay` is on, draws the numbered tab-order path over the page.
|
|
36
38
|
* Default false.
|
|
37
39
|
*/
|
package/dist/report/acr.js
CHANGED
|
@@ -17,6 +17,8 @@ export const ACR_TITLE = 'Evaluation worksheet — not a conformance report';
|
|
|
17
17
|
const NGBR_RULES = {
|
|
18
18
|
'ngbr/unreachable-control': { criteria: ['2.1.1'], ranWhen: 'keyboard' },
|
|
19
19
|
'ngbr/click-without-key': { criteria: ['2.1.1'], ranWhen: 'keyboard' },
|
|
20
|
+
'ngbr/hover-only-content': { criteria: ['2.1.1'], ranWhen: 'keyboard' },
|
|
21
|
+
'ngbr/drag-without-keyboard': { criteria: ['2.1.1', '2.5.7'], ranWhen: 'keyboard' },
|
|
20
22
|
'ngbr/tab-order-mismatch': { criteria: ['2.4.3'], ranWhen: 'keyboard' },
|
|
21
23
|
'ngbr/modal-focus-not-contained': { criteria: ['2.4.3'], ranWhen: 'keyboard' },
|
|
22
24
|
'ngbr/focus-trap': { criteria: ['2.1.2'], ranWhen: 'focusTraps' },
|
|
@@ -67,8 +67,9 @@ export interface ScanPagesOptions {
|
|
|
67
67
|
frameworkPrefixes?: readonly string[];
|
|
68
68
|
/**
|
|
69
69
|
* Also run the keyboard layer in-page — heuristic `ngbr/*` findings for
|
|
70
|
-
* keyboard-unreachable controls, click-without-keyboard handlers,
|
|
71
|
-
*
|
|
70
|
+
* keyboard-unreachable controls, click-without-keyboard handlers, hover-only
|
|
71
|
+
* content, drag and drop with no keyboard way, and tab-order mismatches (the
|
|
72
|
+
* last needs real layout, which headless has).
|
|
72
73
|
* Default false.
|
|
73
74
|
*/
|
|
74
75
|
keyboard?: boolean;
|
package/dist/runner.d.ts
CHANGED
|
@@ -22,8 +22,9 @@ export interface RunOptions {
|
|
|
22
22
|
frameworkPrefixes?: readonly string[];
|
|
23
23
|
/**
|
|
24
24
|
* Also run the keyboard layer — heuristic `ngbr/*` findings for
|
|
25
|
-
* keyboard-unreachable controls, click-without-keyboard handlers,
|
|
26
|
-
* tab-order mismatches.
|
|
25
|
+
* keyboard-unreachable controls, click-without-keyboard handlers, hover-only
|
|
26
|
+
* content, drag and drop with no keyboard way, and tab-order mismatches.
|
|
27
|
+
* Default false.
|
|
27
28
|
*/
|
|
28
29
|
keyboard?: boolean;
|
|
29
30
|
}
|
package/dist/scan.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ export interface A11yFinding {
|
|
|
32
32
|
directives: string[];
|
|
33
33
|
/** CSS selector axe reported for the node. */
|
|
34
34
|
target: string;
|
|
35
|
+
/**
|
|
36
|
+
* A selector that matches only this node, when `target` can match others.
|
|
37
|
+
* Set by the keyboard layer; the overlay uses it to find the node. Not part of
|
|
38
|
+
* a finding's identity in a baseline.
|
|
39
|
+
*/
|
|
40
|
+
locator?: string;
|
|
35
41
|
html: string;
|
|
36
42
|
}
|
|
37
43
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
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",
|
|
@@ -71,15 +71,19 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"esbuild": "^0.28.2",
|
|
73
73
|
"playwright": "^1.40.0",
|
|
74
|
-
"@analogjs/vite-plugin-angular": "^2.
|
|
75
|
-
"@analogjs/vitest-angular": "^2.
|
|
76
|
-
"@angular/build": "^22.1
|
|
77
|
-
"@angular/
|
|
78
|
-
"@angular/
|
|
79
|
-
"@angular/compiler
|
|
80
|
-
"@angular/
|
|
81
|
-
"@angular/
|
|
82
|
-
"@angular/
|
|
74
|
+
"@analogjs/vite-plugin-angular": "^2.8.0",
|
|
75
|
+
"@analogjs/vitest-angular": "^2.8.0",
|
|
76
|
+
"@angular/build": "^22.2.1",
|
|
77
|
+
"@angular/cdk": "^22.2.1",
|
|
78
|
+
"@angular/common": "^22.2.1",
|
|
79
|
+
"@angular/compiler": "^22.2.1",
|
|
80
|
+
"@angular/compiler-cli": "^22.2.1",
|
|
81
|
+
"@angular/core": "^22.2.1",
|
|
82
|
+
"@angular/forms": "^22.2.1",
|
|
83
|
+
"@angular/platform-browser": "^22.2.1",
|
|
84
|
+
"@angular/platform-browser-dynamic": "^22.2.1",
|
|
85
|
+
"@emnapi/core": "^1.11.3",
|
|
86
|
+
"@emnapi/runtime": "^1.11.3",
|
|
83
87
|
"@oxc-project/runtime": "^0.149.0",
|
|
84
88
|
"@types/node": "^26.5.0",
|
|
85
89
|
"jsdom": "^30.0.1",
|