@ngbracket/a11y-devtools 0.18.6 → 0.19.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 +16 -0
- package/dist/inpage.global.js +90 -0
- package/dist/keyboard/focus-walk.js +2 -0
- package/dist/keyboard/keyboard-scan.js +2 -0
- package/dist/report/acr.js +8 -8
- package/dist/report/format.js +5 -0
- package/dist/report/html.js +4 -0
- package/dist/report/wcag.d.ts +21 -0
- package/dist/report/wcag.js +33 -0
- package/dist/report.js +5 -1
- package/dist/scan.d.ts +7 -0
- package/dist/scan.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.19.0
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- Each finding now links to the WCAG criteria it relates to, in the
|
|
11
|
+
[NgBracket accessibility reference](https://ngbracket.com/reference). The
|
|
12
|
+
console, the Markdown report and the HTML report show a link such as
|
|
13
|
+
"WCAG 1.4.3 Contrast (Minimum)" after the axe rule link, which stays as it
|
|
14
|
+
was. The reference page says what the criterion asks, where Angular apps
|
|
15
|
+
usually fail it and how to check it.
|
|
16
|
+
- Every finding has a new `wcag` field listing the WCAG 2.2 A and AA
|
|
17
|
+
criteria its rule checks, such as `['1.4.3']`, in the JSON report too.
|
|
18
|
+
axe findings take theirs from the rule's tags. axe's best-practice rules
|
|
19
|
+
have none, so they get no link. The tool's own `ngbr/*` rules use the
|
|
20
|
+
criteria on their docs pages, such as `['2.1.2']` for `ngbr/focus-trap`.
|
|
21
|
+
|
|
6
22
|
## 0.18.6
|
|
7
23
|
|
|
8
24
|
### Fixed
|
package/dist/inpage.global.js
CHANGED
|
@@ -35003,6 +35003,93 @@
|
|
|
35003
35003
|
return false;
|
|
35004
35004
|
}
|
|
35005
35005
|
|
|
35006
|
+
// dist/report/wcag.js
|
|
35007
|
+
var WCAG22_A_AA = [
|
|
35008
|
+
{ id: "1.1.1", name: "Non-text Content", level: "A", slug: "non-text-content" },
|
|
35009
|
+
{ id: "1.2.1", name: "Audio-only and Video-only (Prerecorded)", level: "A", slug: "audio-only-and-video-only-prerecorded" },
|
|
35010
|
+
{ id: "1.2.2", name: "Captions (Prerecorded)", level: "A", slug: "captions-prerecorded" },
|
|
35011
|
+
{ id: "1.2.3", name: "Audio Description or Media Alternative (Prerecorded)", level: "A", slug: "audio-description-or-media-alternative-prerecorded" },
|
|
35012
|
+
{ id: "1.2.4", name: "Captions (Live)", level: "AA", slug: "captions-live" },
|
|
35013
|
+
{ id: "1.2.5", name: "Audio Description (Prerecorded)", level: "AA", slug: "audio-description-prerecorded" },
|
|
35014
|
+
{ id: "1.3.1", name: "Info and Relationships", level: "A", slug: "info-and-relationships" },
|
|
35015
|
+
{ id: "1.3.2", name: "Meaningful Sequence", level: "A", slug: "meaningful-sequence" },
|
|
35016
|
+
{ id: "1.3.3", name: "Sensory Characteristics", level: "A", slug: "sensory-characteristics" },
|
|
35017
|
+
{ id: "1.3.4", name: "Orientation", level: "AA", slug: "orientation" },
|
|
35018
|
+
{ id: "1.3.5", name: "Identify Input Purpose", level: "AA", slug: "identify-input-purpose" },
|
|
35019
|
+
{ id: "1.4.1", name: "Use of Color", level: "A", slug: "use-of-color" },
|
|
35020
|
+
{ id: "1.4.2", name: "Audio Control", level: "A", slug: "audio-control" },
|
|
35021
|
+
{ id: "1.4.3", name: "Contrast (Minimum)", level: "AA", slug: "contrast-minimum" },
|
|
35022
|
+
{ id: "1.4.4", name: "Resize Text", level: "AA", slug: "resize-text" },
|
|
35023
|
+
{ id: "1.4.5", name: "Images of Text", level: "AA", slug: "images-of-text" },
|
|
35024
|
+
{ id: "1.4.10", name: "Reflow", level: "AA", slug: "reflow" },
|
|
35025
|
+
{ id: "1.4.11", name: "Non-text Contrast", level: "AA", slug: "non-text-contrast" },
|
|
35026
|
+
{ id: "1.4.12", name: "Text Spacing", level: "AA", slug: "text-spacing" },
|
|
35027
|
+
{ id: "1.4.13", name: "Content on Hover or Focus", level: "AA", slug: "content-on-hover-or-focus" },
|
|
35028
|
+
{ id: "2.1.1", name: "Keyboard", level: "A", slug: "keyboard" },
|
|
35029
|
+
{ id: "2.1.2", name: "No Keyboard Trap", level: "A", slug: "no-keyboard-trap" },
|
|
35030
|
+
{ id: "2.1.4", name: "Character Key Shortcuts", level: "A", slug: "character-key-shortcuts" },
|
|
35031
|
+
{ id: "2.2.1", name: "Timing Adjustable", level: "A", slug: "timing-adjustable" },
|
|
35032
|
+
{ id: "2.2.2", name: "Pause, Stop, Hide", level: "A", slug: "pause-stop-hide" },
|
|
35033
|
+
{ id: "2.3.1", name: "Three Flashes or Below Threshold", level: "A", slug: "three-flashes-or-below-threshold" },
|
|
35034
|
+
{ id: "2.4.1", name: "Bypass Blocks", level: "A", slug: "bypass-blocks" },
|
|
35035
|
+
{ id: "2.4.2", name: "Page Titled", level: "A", slug: "page-titled" },
|
|
35036
|
+
{ id: "2.4.3", name: "Focus Order", level: "A", slug: "focus-order" },
|
|
35037
|
+
{ id: "2.4.4", name: "Link Purpose (In Context)", level: "A", slug: "link-purpose-in-context" },
|
|
35038
|
+
{ id: "2.4.5", name: "Multiple Ways", level: "AA", slug: "multiple-ways" },
|
|
35039
|
+
{ id: "2.4.6", name: "Headings and Labels", level: "AA", slug: "headings-and-labels" },
|
|
35040
|
+
{ id: "2.4.7", name: "Focus Visible", level: "AA", slug: "focus-visible" },
|
|
35041
|
+
{ id: "2.4.11", name: "Focus Not Obscured (Minimum)", level: "AA", slug: "focus-not-obscured-minimum" },
|
|
35042
|
+
{ id: "2.5.1", name: "Pointer Gestures", level: "A", slug: "pointer-gestures" },
|
|
35043
|
+
{ id: "2.5.2", name: "Pointer Cancellation", level: "A", slug: "pointer-cancellation" },
|
|
35044
|
+
{ id: "2.5.3", name: "Label in Name", level: "A", slug: "label-in-name" },
|
|
35045
|
+
{ id: "2.5.4", name: "Motion Actuation", level: "A", slug: "motion-actuation" },
|
|
35046
|
+
{ id: "2.5.7", name: "Dragging Movements", level: "AA", slug: "dragging-movements" },
|
|
35047
|
+
{ id: "2.5.8", name: "Target Size (Minimum)", level: "AA", slug: "target-size-minimum" },
|
|
35048
|
+
{ id: "3.1.1", name: "Language of Page", level: "A", slug: "language-of-page" },
|
|
35049
|
+
{ id: "3.1.2", name: "Language of Parts", level: "AA", slug: "language-of-parts" },
|
|
35050
|
+
{ id: "3.2.1", name: "On Focus", level: "A", slug: "on-focus" },
|
|
35051
|
+
{ id: "3.2.2", name: "On Input", level: "A", slug: "on-input" },
|
|
35052
|
+
{ id: "3.2.3", name: "Consistent Navigation", level: "AA", slug: "consistent-navigation" },
|
|
35053
|
+
{ id: "3.2.4", name: "Consistent Identification", level: "AA", slug: "consistent-identification" },
|
|
35054
|
+
{ id: "3.2.6", name: "Consistent Help", level: "A", slug: "consistent-help" },
|
|
35055
|
+
{ id: "3.3.1", name: "Error Identification", level: "A", slug: "error-identification" },
|
|
35056
|
+
{ id: "3.3.2", name: "Labels or Instructions", level: "A", slug: "labels-or-instructions" },
|
|
35057
|
+
{ id: "3.3.3", name: "Error Suggestion", level: "AA", slug: "error-suggestion" },
|
|
35058
|
+
{ id: "3.3.4", name: "Error Prevention (Legal, Financial, Data)", level: "AA", slug: "error-prevention-legal-financial-data" },
|
|
35059
|
+
{ id: "3.3.7", name: "Redundant Entry", level: "A", slug: "redundant-entry" },
|
|
35060
|
+
{ id: "3.3.8", name: "Accessible Authentication (Minimum)", level: "AA", slug: "accessible-authentication-minimum" },
|
|
35061
|
+
{ id: "4.1.2", name: "Name, Role, Value", level: "A", slug: "name-role-value" },
|
|
35062
|
+
{ id: "4.1.3", name: "Status Messages", level: "AA", slug: "status-messages" }
|
|
35063
|
+
];
|
|
35064
|
+
function understandingUrl(criterion) {
|
|
35065
|
+
return `https://www.w3.org/WAI/WCAG22/Understanding/${criterion.slug}.html`;
|
|
35066
|
+
}
|
|
35067
|
+
function criterionForTag(tag) {
|
|
35068
|
+
const digits = /^wcag(\d{3,4})$/.exec(tag)?.[1];
|
|
35069
|
+
return digits ? BY_DIGITS.get(digits) : void 0;
|
|
35070
|
+
}
|
|
35071
|
+
var BY_DIGITS = new Map(WCAG22_A_AA.map((c) => [c.id.replace(/\./g, ""), c]));
|
|
35072
|
+
var REFERENCE_WCAG_URL = "https://ngbracket.com/reference/wcag";
|
|
35073
|
+
function referenceUrl(criterion) {
|
|
35074
|
+
return `${REFERENCE_WCAG_URL}/${criterion.slug}`;
|
|
35075
|
+
}
|
|
35076
|
+
var NGBR_RULE_CRITERIA = {
|
|
35077
|
+
"ngbr/unreachable-control": ["2.1.1"],
|
|
35078
|
+
"ngbr/click-without-key": ["2.1.1"],
|
|
35079
|
+
"ngbr/hover-only-content": ["2.1.1"],
|
|
35080
|
+
"ngbr/drag-without-keyboard": ["2.1.1", "2.5.7"],
|
|
35081
|
+
"ngbr/tab-order-mismatch": ["2.4.3"],
|
|
35082
|
+
"ngbr/modal-focus-not-contained": ["2.4.3"],
|
|
35083
|
+
"ngbr/focus-trap": ["2.1.2"]
|
|
35084
|
+
};
|
|
35085
|
+
function ngbrRuleCriteria(id) {
|
|
35086
|
+
return [...NGBR_RULE_CRITERIA[id] ?? []];
|
|
35087
|
+
}
|
|
35088
|
+
function findingCriteria(finding) {
|
|
35089
|
+
const ids = new Set(finding.wcag ?? NGBR_RULE_CRITERIA[finding.id] ?? []);
|
|
35090
|
+
return WCAG22_A_AA.filter((c) => ids.has(c.id));
|
|
35091
|
+
}
|
|
35092
|
+
|
|
35006
35093
|
// dist/keyboard/keyboard-scan.js
|
|
35007
35094
|
var INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
35008
35095
|
"button",
|
|
@@ -35240,6 +35327,7 @@
|
|
|
35240
35327
|
impact,
|
|
35241
35328
|
help,
|
|
35242
35329
|
helpUrl,
|
|
35330
|
+
wcag: ngbrRuleCriteria(id),
|
|
35243
35331
|
component: appComponentFromPath(componentPath, prefixes),
|
|
35244
35332
|
componentPath,
|
|
35245
35333
|
directives: resolveDirectiveNames(element),
|
|
@@ -35456,6 +35544,7 @@
|
|
|
35456
35544
|
impact: shiftTabEscapes ? "moderate" : "serious",
|
|
35457
35545
|
help: `Keyboard trap: ${where}${reach}.${shift} If this widget deliberately keeps Tab (e.g. a code editor), it must tell users how to leave (such as Escape); otherwise let Tab move focus on. Found by real Tab presses \u2014 verify manually.`,
|
|
35458
35546
|
helpUrl: FOCUS_TRAP_DOCS,
|
|
35547
|
+
wcag: ngbrRuleCriteria("ngbr/focus-trap"),
|
|
35459
35548
|
component: appComponentFromPath(componentPath, frameworkPrefixes),
|
|
35460
35549
|
componentPath,
|
|
35461
35550
|
directives: resolveDirectiveNames(owner),
|
|
@@ -35624,6 +35713,7 @@
|
|
|
35624
35713
|
impact: violation.impact ?? null,
|
|
35625
35714
|
help: violation.help,
|
|
35626
35715
|
helpUrl: violation.helpUrl,
|
|
35716
|
+
wcag: violation.tags.flatMap((tag) => criterionForTag(tag)?.id ?? []),
|
|
35627
35717
|
component: appComponentFromPath(componentPath, frameworkPrefixes),
|
|
35628
35718
|
componentPath,
|
|
35629
35719
|
directives: element ? resolveDirectiveNames(element) : [],
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import { appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, resolveComponentPath, resolveDirectiveNames, } from '../attribution.js';
|
|
22
22
|
import { shortHtml, shortSelector } from './keyboard-scan.js';
|
|
23
23
|
import { tabSequence } from './tab-sequence.js';
|
|
24
|
+
import { ngbrRuleCriteria } from '../report/wcag.js';
|
|
24
25
|
/**
|
|
25
26
|
* Classify a Tab walk. Browsers pass focus through `<body>` (null here) when Tab
|
|
26
27
|
* wraps off the end of the page, so an element seen again *after* a null means
|
|
@@ -140,6 +141,7 @@ export function createFocusWalkProbe(doc = document, frameworkPrefixes = DEFAULT
|
|
|
140
141
|
`Tab (e.g. a code editor), it must tell users how to leave (such as Escape); otherwise ` +
|
|
141
142
|
`let Tab move focus on. Found by real Tab presses — verify manually.`,
|
|
142
143
|
helpUrl: FOCUS_TRAP_DOCS,
|
|
144
|
+
wcag: ngbrRuleCriteria('ngbr/focus-trap'),
|
|
143
145
|
component: appComponentFromPath(componentPath, frameworkPrefixes),
|
|
144
146
|
componentPath,
|
|
145
147
|
directives: resolveDirectiveNames(owner),
|
|
@@ -17,6 +17,7 @@ import { findUncontainedModals } from './focus-trap.js';
|
|
|
17
17
|
import { hoverSignal } from './hover-content.js';
|
|
18
18
|
import { dragGroups, dragHandles, hasMoveControl } from './drag-drop.js';
|
|
19
19
|
import { blockingModalDialog } from '../top-layer.js';
|
|
20
|
+
import { ngbrRuleCriteria } from '../report/wcag.js';
|
|
20
21
|
import { OVERLAY_EXCLUDE_SELECTOR } from '../overlay.js';
|
|
21
22
|
/** WAI-ARIA roles that make a non-native element behave as an interactive control. */
|
|
22
23
|
const INTERACTIVE_ROLES = new Set([
|
|
@@ -399,6 +400,7 @@ export function scanKeyboard(root = document, options = {}) {
|
|
|
399
400
|
impact,
|
|
400
401
|
help,
|
|
401
402
|
helpUrl,
|
|
403
|
+
wcag: ngbrRuleCriteria(id),
|
|
402
404
|
component: appComponentFromPath(componentPath, prefixes),
|
|
403
405
|
componentPath,
|
|
404
406
|
directives: resolveDirectiveNames(element),
|
package/dist/report/acr.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { impactRank } from './format.js';
|
|
3
3
|
import { escapeHtml, safeHref, STYLES } from './html.js';
|
|
4
|
-
import { criterionForTag, understandingUrl, WCAG22_A_AA } from './wcag.js';
|
|
4
|
+
import { criterionForTag, NGBR_RULE_CRITERIA, understandingUrl, WCAG22_A_AA } from './wcag.js';
|
|
5
5
|
export const ACR_RESULT_LABELS = {
|
|
6
6
|
failures: 'Automated failures found',
|
|
7
7
|
'possible-failures': 'Possible failures found — verify manually',
|
|
@@ -15,13 +15,13 @@ export const ACR_TITLE = 'Evaluation worksheet — not a conformance report';
|
|
|
15
15
|
* documented way out; an order mismatch can be deliberate).
|
|
16
16
|
*/
|
|
17
17
|
const NGBR_RULES = {
|
|
18
|
-
'ngbr/unreachable-control': { criteria: ['
|
|
19
|
-
'ngbr/click-without-key': { criteria: ['
|
|
20
|
-
'ngbr/hover-only-content': { criteria: ['
|
|
21
|
-
'ngbr/drag-without-keyboard': { criteria: ['
|
|
22
|
-
'ngbr/tab-order-mismatch': { criteria: ['
|
|
23
|
-
'ngbr/modal-focus-not-contained': { criteria: ['
|
|
24
|
-
'ngbr/focus-trap': { criteria: ['
|
|
18
|
+
'ngbr/unreachable-control': { criteria: NGBR_RULE_CRITERIA['ngbr/unreachable-control'], ranWhen: 'keyboard' },
|
|
19
|
+
'ngbr/click-without-key': { criteria: NGBR_RULE_CRITERIA['ngbr/click-without-key'], ranWhen: 'keyboard' },
|
|
20
|
+
'ngbr/hover-only-content': { criteria: NGBR_RULE_CRITERIA['ngbr/hover-only-content'], ranWhen: 'keyboard' },
|
|
21
|
+
'ngbr/drag-without-keyboard': { criteria: NGBR_RULE_CRITERIA['ngbr/drag-without-keyboard'], ranWhen: 'keyboard' },
|
|
22
|
+
'ngbr/tab-order-mismatch': { criteria: NGBR_RULE_CRITERIA['ngbr/tab-order-mismatch'], ranWhen: 'keyboard' },
|
|
23
|
+
'ngbr/modal-focus-not-contained': { criteria: NGBR_RULE_CRITERIA['ngbr/modal-focus-not-contained'], ranWhen: 'keyboard' },
|
|
24
|
+
'ngbr/focus-trap': { criteria: NGBR_RULE_CRITERIA['ngbr/focus-trap'], ranWhen: 'focusTraps' },
|
|
25
25
|
};
|
|
26
26
|
export function loadAxeRules() {
|
|
27
27
|
const axe = createRequire(import.meta.url)('axe-core');
|
package/dist/report/format.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findingCriteria, referenceUrl } from './wcag.js';
|
|
1
2
|
/** One-line explanation for a dark-only page, shared by the Markdown and HTML reports. */
|
|
2
3
|
export const DARK_ONLY_NOTE = 'Dark mode: lists only issues that don’t also appear in light mode on this route.';
|
|
3
4
|
/**
|
|
@@ -228,6 +229,10 @@ export function toMarkdown(report, diff) {
|
|
|
228
229
|
lines.push(`- ${isNew}**${finding.impact ?? 'n/a'} · ${finding.id}**: ${finding.help}${suffix}`);
|
|
229
230
|
lines.push(` - \`${finding.target}\``);
|
|
230
231
|
lines.push(` - ${finding.helpUrl}`);
|
|
232
|
+
const criteria = findingCriteria(finding);
|
|
233
|
+
if (criteria.length) {
|
|
234
|
+
lines.push(` - WCAG ${criteria.map((c) => `[${c.id} ${c.name}](${referenceUrl(c)})`).join(', ')}`);
|
|
235
|
+
}
|
|
231
236
|
}
|
|
232
237
|
lines.push('');
|
|
233
238
|
}
|
package/dist/report/html.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { addedBySeverity, COVERAGE_URL, DARK_ONLY_NOTE, formatStep, REPORT_SCOPE_NOTE, REPORT_TITLE, bySeverity, distinctRuleCount, groupByComponent, viaNames, walkthroughCapNote, WALKTHROUGH_NOTE, } from './format.js';
|
|
2
|
+
import { findingCriteria, referenceUrl } from './wcag.js';
|
|
2
3
|
/**
|
|
3
4
|
* A single self-contained HTML report: inline CSS, no scripts, no external
|
|
4
5
|
* requests — so it can be attached to a CI run, emailed, or opened offline.
|
|
@@ -160,6 +161,9 @@ export function toHtml(report, diff) {
|
|
|
160
161
|
if (href) {
|
|
161
162
|
out.push(` · <a href="${href}">Rule reference<span class="visually-hidden"> for ${escapeHtml(finding.id)}</span></a>`);
|
|
162
163
|
}
|
|
164
|
+
for (const c of findingCriteria(finding)) {
|
|
165
|
+
out.push(` · <a href="${referenceUrl(c)}">WCAG ${escapeHtml(c.id)} ${escapeHtml(c.name)}</a>`);
|
|
166
|
+
}
|
|
163
167
|
out.push('</p>');
|
|
164
168
|
out.push('</li>');
|
|
165
169
|
}
|
package/dist/report/wcag.d.ts
CHANGED
|
@@ -22,3 +22,24 @@ export declare function understandingUrl(criterion: WcagCriterion): string;
|
|
|
22
22
|
* {@link WCAG22_A_AA}. Dropping the dots is unambiguous within the A/AA set.
|
|
23
23
|
*/
|
|
24
24
|
export declare function criterionForTag(tag: string): WcagCriterion | undefined;
|
|
25
|
+
/** Where the NgBracket accessibility reference explains each criterion. */
|
|
26
|
+
export declare const REFERENCE_WCAG_URL = "https://ngbracket.com/reference/wcag";
|
|
27
|
+
/** The criterion's page in the NgBracket accessibility reference. */
|
|
28
|
+
export declare function referenceUrl(criterion: WcagCriterion): string;
|
|
29
|
+
/**
|
|
30
|
+
* The criteria the tool's own `ngbr/*` rules check, from the "Standard" row of
|
|
31
|
+
* each rule's docs page. axe findings take theirs from axe's tags.
|
|
32
|
+
*/
|
|
33
|
+
export declare const NGBR_RULE_CRITERIA: Readonly<Record<string, readonly string[]>>;
|
|
34
|
+
/** The `wcag` list for an `ngbr/*` finding; [] for an unknown id. */
|
|
35
|
+
export declare function ngbrRuleCriteria(id: string): string[];
|
|
36
|
+
/**
|
|
37
|
+
* The WCAG 2.2 A and AA criteria a finding relates to, in document order:
|
|
38
|
+
* its `wcag` list, or for an `ngbr/*` finding saved before 0.19.0 (no `wcag`),
|
|
39
|
+
* the rule's fixed list. Empty for axe's best-practice rules, which have no
|
|
40
|
+
* criterion.
|
|
41
|
+
*/
|
|
42
|
+
export declare function findingCriteria(finding: {
|
|
43
|
+
id: string;
|
|
44
|
+
wcag?: readonly string[];
|
|
45
|
+
}): WcagCriterion[];
|
package/dist/report/wcag.js
CHANGED
|
@@ -74,3 +74,36 @@ export function criterionForTag(tag) {
|
|
|
74
74
|
return digits ? BY_DIGITS.get(digits) : undefined;
|
|
75
75
|
}
|
|
76
76
|
const BY_DIGITS = new Map(WCAG22_A_AA.map((c) => [c.id.replace(/\./g, ''), c]));
|
|
77
|
+
/** Where the NgBracket accessibility reference explains each criterion. */
|
|
78
|
+
export const REFERENCE_WCAG_URL = 'https://ngbracket.com/reference/wcag';
|
|
79
|
+
/** The criterion's page in the NgBracket accessibility reference. */
|
|
80
|
+
export function referenceUrl(criterion) {
|
|
81
|
+
return `${REFERENCE_WCAG_URL}/${criterion.slug}`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The criteria the tool's own `ngbr/*` rules check, from the "Standard" row of
|
|
85
|
+
* each rule's docs page. axe findings take theirs from axe's tags.
|
|
86
|
+
*/
|
|
87
|
+
export const NGBR_RULE_CRITERIA = {
|
|
88
|
+
'ngbr/unreachable-control': ['2.1.1'],
|
|
89
|
+
'ngbr/click-without-key': ['2.1.1'],
|
|
90
|
+
'ngbr/hover-only-content': ['2.1.1'],
|
|
91
|
+
'ngbr/drag-without-keyboard': ['2.1.1', '2.5.7'],
|
|
92
|
+
'ngbr/tab-order-mismatch': ['2.4.3'],
|
|
93
|
+
'ngbr/modal-focus-not-contained': ['2.4.3'],
|
|
94
|
+
'ngbr/focus-trap': ['2.1.2'],
|
|
95
|
+
};
|
|
96
|
+
/** The `wcag` list for an `ngbr/*` finding; [] for an unknown id. */
|
|
97
|
+
export function ngbrRuleCriteria(id) {
|
|
98
|
+
return [...(NGBR_RULE_CRITERIA[id] ?? [])];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The WCAG 2.2 A and AA criteria a finding relates to, in document order:
|
|
102
|
+
* its `wcag` list, or for an `ngbr/*` finding saved before 0.19.0 (no `wcag`),
|
|
103
|
+
* the rule's fixed list. Empty for axe's best-practice rules, which have no
|
|
104
|
+
* criterion.
|
|
105
|
+
*/
|
|
106
|
+
export function findingCriteria(finding) {
|
|
107
|
+
const ids = new Set(finding.wcag ?? NGBR_RULE_CRITERIA[finding.id] ?? []);
|
|
108
|
+
return WCAG22_A_AA.filter((c) => ids.has(c.id));
|
|
109
|
+
}
|
package/dist/report.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { groupByComponent } from './report/format.js';
|
|
2
|
+
import { findingCriteria, referenceUrl } from './report/wcag.js';
|
|
2
3
|
/**
|
|
3
4
|
* Log findings grouped by the component that owns them — the readable form the
|
|
4
5
|
* attribution makes possible ("♿ UserCardComponent — 2 issues" beats a list of
|
|
@@ -15,7 +16,10 @@ export function logFindings(findings, logger = console) {
|
|
|
15
16
|
logger.groupCollapsed(`♿ ${component} — ${items.length} issue(s)`);
|
|
16
17
|
for (const finding of items) {
|
|
17
18
|
const via = finding.directives.length ? ` [via ${finding.directives.join(', ')}]` : '';
|
|
18
|
-
logger.warn(`${finding.impact ?? 'n/a'} · ${finding.id}: ${finding.help}${via}`, `\n ${finding.target}\n ${finding.helpUrl}`
|
|
19
|
+
logger.warn(`${finding.impact ?? 'n/a'} · ${finding.id}: ${finding.help}${via}`, `\n ${finding.target}\n ${finding.helpUrl}` +
|
|
20
|
+
findingCriteria(finding)
|
|
21
|
+
.map((c) => `\n WCAG ${c.id} ${c.name}: ${referenceUrl(c)}`)
|
|
22
|
+
.join(''));
|
|
19
23
|
}
|
|
20
24
|
logger.groupEnd();
|
|
21
25
|
}
|
package/dist/scan.d.ts
CHANGED
|
@@ -24,6 +24,13 @@ export interface A11yFinding {
|
|
|
24
24
|
impact: Impact;
|
|
25
25
|
help: string;
|
|
26
26
|
helpUrl: string;
|
|
27
|
+
/**
|
|
28
|
+
* WCAG 2.2 A and AA criteria the rule checks, e.g. `['1.4.3']`: from the
|
|
29
|
+
* axe rule's tags, or from the docs page of an `ngbr/*` rule. Empty for
|
|
30
|
+
* axe's best-practice rules. Optional because reports saved before 0.19.0
|
|
31
|
+
* don't have it.
|
|
32
|
+
*/
|
|
33
|
+
wcag?: string[];
|
|
27
34
|
/** Owning component name, or null when attribution isn't available (prod). */
|
|
28
35
|
component: string | null;
|
|
29
36
|
/** Owning components from the flagged node up to the root, nearest first, each once; [] in prod. */
|
package/dist/scan.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { appComponentFromPath, DEFAULT_FRAMEWORK_PREFIXES, resolveComponentPath, resolveDirectiveNames, } from './attribution.js';
|
|
2
2
|
import { OVERLAY_EXCLUDE_SELECTOR } from './overlay.js';
|
|
3
3
|
import { scanKeyboard } from './keyboard/keyboard-scan.js';
|
|
4
|
+
import { criterionForTag } from './report/wcag.js';
|
|
4
5
|
// axe-core is a singleton and throws if a run starts while another is in flight.
|
|
5
6
|
// Chain runs so overlapping callers (e.g. rapid rescans) serialize safely.
|
|
6
7
|
let runChain = Promise.resolve();
|
|
@@ -39,6 +40,7 @@ async function runAxeOnce(root, options, scanOptions) {
|
|
|
39
40
|
impact: (violation.impact ?? null),
|
|
40
41
|
help: violation.help,
|
|
41
42
|
helpUrl: violation.helpUrl,
|
|
43
|
+
wcag: violation.tags.flatMap((tag) => criterionForTag(tag)?.id ?? []),
|
|
42
44
|
component: appComponentFromPath(componentPath, frameworkPrefixes),
|
|
43
45
|
componentPath,
|
|
44
46
|
directives: element ? resolveDirectiveNames(element) : [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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",
|