@ngbracket/a11y-devtools 0.15.5 → 0.15.6
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 +20 -0
- package/README.md +1 -1
- package/dist/inpage.global.js +1 -1
- package/dist/keyboard/accname.js +11 -5
- package/dist/overlay.d.ts +1 -1
- package/dist/overlay.js +3 -3
- package/dist/provider.js +63 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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.6
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- **The Focus preview card is now headed "Focus preview".** It used to say
|
|
11
|
+
"Accessibility-tree preview", which didn't match the "Focus preview" setting
|
|
12
|
+
in the pill menu, so the card and its switch were hard to connect. It is
|
|
13
|
+
still labelled a computed approximation.
|
|
14
|
+
- **Turning Focus preview on shows the card without waiting for focus to
|
|
15
|
+
move.** Before, nothing appeared until focus next moved. Now, switching the
|
|
16
|
+
setting on describes the control that already has focus; switching the whole
|
|
17
|
+
tool on does the same once its first scan finishes. When you toggle it
|
|
18
|
+
from the pill menu, it describes the page control you were on before.
|
|
19
|
+
- **The Focus preview no longer shows an empty name while a scan is running.**
|
|
20
|
+
axe can't compute an accessible name during its own run, so a control
|
|
21
|
+
focused mid-scan showed "(no accessible name)". The preview now waits for the
|
|
22
|
+
scan to finish and describes only the latest focus. A `describeElement` call
|
|
23
|
+
made during a scan also no longer tears down the scan's axe tree, which had
|
|
24
|
+
silently dropped that scan's findings.
|
|
25
|
+
|
|
6
26
|
## 0.15.5
|
|
7
27
|
|
|
8
28
|
### Fixed
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Part of the `@ngbracket` Angular tooling family.
|
|
|
26
26
|
- **Dark mode**: scan your dark theme too, whether it follows the OS setting, a
|
|
27
27
|
class, an attribute, or custom logic.
|
|
28
28
|
- **Keyboard & Focus Mode**: tab-order visualisation, keyboard findings,
|
|
29
|
-
|
|
29
|
+
Focus preview (computed role, name and state), and keyboard-trap detection with real Tab presses.
|
|
30
30
|
- **Zero production weight**: a no-op in production; axe-core is never loaded.
|
|
31
31
|
|
|
32
32
|
## Install
|
package/dist/inpage.global.js
CHANGED
|
@@ -34483,7 +34483,7 @@
|
|
|
34483
34483
|
function buildAxPanelContent(doc, data) {
|
|
34484
34484
|
const nodes = [];
|
|
34485
34485
|
const header = doc.createElement("div");
|
|
34486
|
-
header.textContent = "
|
|
34486
|
+
header.textContent = "Focus preview \u2014 computed approximation";
|
|
34487
34487
|
Object.assign(header.style, {
|
|
34488
34488
|
fontWeight: "700",
|
|
34489
34489
|
fontSize: "10px",
|
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
|
@@ -74,7 +74,7 @@ export function createOverlay(options = {}) {
|
|
|
74
74
|
connector.setAttribute('opacity', '0.7');
|
|
75
75
|
svg.appendChild(connector);
|
|
76
76
|
container.appendChild(svg); // under the badges, which are appended later
|
|
77
|
-
// The
|
|
77
|
+
// The Focus preview panel: a fixed card that follows focus. Hidden
|
|
78
78
|
// until renderAxPanel is called with data. Marked with OVERLAY_ATTR so scans
|
|
79
79
|
// never flag the tool's own UI.
|
|
80
80
|
const axPanel = doc.createElement('div');
|
|
@@ -223,11 +223,11 @@ export function createOverlay(options = {}) {
|
|
|
223
223
|
}
|
|
224
224
|
return { render, renderTabOrder, renderAxPanel, clear, clearTabOrder, destroy };
|
|
225
225
|
}
|
|
226
|
-
/** The rows of the
|
|
226
|
+
/** The rows of the Focus preview panel, honesty header first. */
|
|
227
227
|
function buildAxPanelContent(doc, data) {
|
|
228
228
|
const nodes = [];
|
|
229
229
|
const header = doc.createElement('div');
|
|
230
|
-
header.textContent = '
|
|
230
|
+
header.textContent = 'Focus preview — computed approximation';
|
|
231
231
|
Object.assign(header.style, {
|
|
232
232
|
fontWeight: '700',
|
|
233
233
|
fontSize: '10px',
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.6",
|
|
4
4
|
"description": "Dev-only in-app accessibility auditing for Angular that maps each axe violation back to the component that rendered it — the attribution React overlay tools can't do.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Duncan Faulkner",
|