@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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,88 @@
|
|
|
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.17.0
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- New keyboard rule `ngbr/drag-without-keyboard`. It reports a list whose items
|
|
11
|
+
move by drag and drop when the tool finds no keyboard way to move them.
|
|
12
|
+
Angular CDK drag and drop has no keyboard support of its own, so a list of
|
|
13
|
+
rows with `cdkDragHandle` icons is mouse-only unless the app adds one. The
|
|
14
|
+
rule finds drag items by the `cdk-drag` class inside a `cdk-drop-list`, and
|
|
15
|
+
by `draggable="true"` when a parent holds two or more, in any build. It
|
|
16
|
+
reports each list once. It skips a list with a tab stop in or next to it
|
|
17
|
+
whose name says it moves an item ("Move up", "Reorder", an arrow, a Material
|
|
18
|
+
`arrow_upward` icon). Serious when the keyboard can't reach a drag handle of a
|
|
19
|
+
CDK list; moderate for a native `draggable` list. A handle or item with a
|
|
20
|
+
`tabindex` counts as reachable when a drag list on the page has a tab stop,
|
|
21
|
+
as in a board where one card is the tab stop and the arrow keys move to the
|
|
22
|
+
rest. Moderate in a dev build when a handle is reachable but no Angular key
|
|
23
|
+
listener sits on the handle, its item, the list, or the elements up to and
|
|
24
|
+
including the component that holds the list. Maps to WCAG 2.1.1 and
|
|
25
|
+
2.5.7 in the ACR worksheet.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- The tab-order layer now hides the page's tab stops while an Angular Material
|
|
30
|
+
dialog is open. Material 22 opens `mat-dialog` with `aria-modal="false"` by
|
|
31
|
+
default and hides the page from screen readers with `aria-hidden`. The
|
|
32
|
+
scanner only looked for the CDK focus trap around `aria-modal="true"`
|
|
33
|
+
elements, so it missed the trap and numbered the page's stops under the
|
|
34
|
+
dialog as well as the dialog's own. It now finds the trap around any
|
|
35
|
+
`mat-dialog-container`, `.cdk-dialog-container` or dialog role. Report mode
|
|
36
|
+
also no longer counts Tab cycling inside a default `mat-dialog` as a
|
|
37
|
+
`ngbr/focus-trap` finding.
|
|
38
|
+
- The scanner now recognises the focus traps in PrimeNG, ngx-bootstrap and
|
|
39
|
+
ng-bootstrap dialogs. PrimeNG and ngx-bootstrap put their sentinels inside
|
|
40
|
+
the dialog, as its first and last tab stops. ng-bootstrap's modal and
|
|
41
|
+
offcanvas trap Tab with a script and no sentinels, so they're recognised by
|
|
42
|
+
element name. Before, the tab-order layer showed the page's stops under these
|
|
43
|
+
dialogs, and `ngbr/modal-focus-not-contained` reported a leak that wasn't
|
|
44
|
+
there.
|
|
45
|
+
|
|
46
|
+
## 0.16.0
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- New keyboard rule `ngbr/hover-only-content`. It reports an element that shows
|
|
51
|
+
content on hover when Tab can't reach it, so keyboard users may never see that
|
|
52
|
+
content. An info icon with a tooltip in a table row is the common case. The
|
|
53
|
+
rule looks for:
|
|
54
|
+
- a tooltip from Angular Material, PrimeNG, ng-bootstrap, ngx-bootstrap,
|
|
55
|
+
ng-zorro, Taiga UI or helipopper, by its directive class in a dev build or
|
|
56
|
+
by its attribute or host class in any build. Moderate. An empty tooltip
|
|
57
|
+
attribute is skipped in every build. In a dev build, a tooltip switched off
|
|
58
|
+
through its directive is skipped too (Material, PrimeNG, ng-bootstrap,
|
|
59
|
+
ngx-bootstrap, ng-zorro and helipopper), and so is Material's
|
|
60
|
+
`matTooltipDisabled` in any build.
|
|
61
|
+
- an HTML `interestfor` attribute. Moderate.
|
|
62
|
+
- an Angular `(mouseenter)`, `(mouseover)`, `(pointerenter)` or
|
|
63
|
+
`(pointerover)` listener (dev builds). Minor, since such a listener can also
|
|
64
|
+
do something else, such as highlight a row.
|
|
65
|
+
- a `title` on an icon with no visible text, unless it repeats the icon's
|
|
66
|
+
`alt` or `aria-label`. Minor.
|
|
67
|
+
|
|
68
|
+
A disabled control with a tooltip, or a wrapper around one, gets its own
|
|
69
|
+
message: a disabled control can't take focus, so use `aria-disabled="true"`
|
|
70
|
+
instead. The rule skips an element inside something Tab reaches (an icon in a
|
|
71
|
+
link), a wrapper around something Tab reaches, and anything inside an
|
|
72
|
+
element already reported. It runs with the keyboard layer and maps to WCAG
|
|
73
|
+
2.1.1 in the ACR worksheet. Like the other keyboard rules, it is a heuristic
|
|
74
|
+
to check by hand.
|
|
75
|
+
|
|
76
|
+
If you gate CI on a baseline, findings from this rule show as new after you
|
|
77
|
+
upgrade. Update the baseline once you've checked them.
|
|
78
|
+
|
|
79
|
+
### Fixed
|
|
80
|
+
|
|
81
|
+
- The overlay now draws each keyboard finding on its own element. Keyboard
|
|
82
|
+
findings use a short selector such as `mat-icon.info`, and when that matched
|
|
83
|
+
an element repeated in every table row, the overlay drew all the findings on
|
|
84
|
+
the first match. Findings now carry a `locator` as well: a selector that
|
|
85
|
+
matches only that element, which the overlay uses. `target` is unchanged, so
|
|
86
|
+
baselines are unaffected.
|
|
87
|
+
|
|
6
88
|
## 0.15.8
|
|
7
89
|
|
|
8
90
|
### Fixed
|
package/dist/attribution.d.ts
CHANGED
|
@@ -76,3 +76,12 @@ export declare function resolveOwningComponentName(node: Element, frameworkPrefi
|
|
|
76
76
|
* can't see. Empty when the debug global is absent or the node has none.
|
|
77
77
|
*/
|
|
78
78
|
export declare function resolveDirectiveNames(node: Element): string[];
|
|
79
|
+
/**
|
|
80
|
+
* The directive instances on `node` with their names, for checks that need to
|
|
81
|
+
* look at an instance (e.g. to tell PrimeNG's `Tooltip` from another library's
|
|
82
|
+
* class of the same name). Empty when the debug global is absent.
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolveDirectives(node: Element): {
|
|
85
|
+
name: string;
|
|
86
|
+
instance: object;
|
|
87
|
+
}[];
|
package/dist/attribution.js
CHANGED
|
@@ -122,6 +122,14 @@ export function resolveOwningComponentName(node, frameworkPrefixes = DEFAULT_FRA
|
|
|
122
122
|
* can't see. Empty when the debug global is absent or the node has none.
|
|
123
123
|
*/
|
|
124
124
|
export function resolveDirectiveNames(node) {
|
|
125
|
+
return resolveDirectives(node).map((d) => d.name);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The directive instances on `node` with their names, for checks that need to
|
|
129
|
+
* look at an instance (e.g. to tell PrimeNG's `Tooltip` from another library's
|
|
130
|
+
* class of the same name). Empty when the debug global is absent.
|
|
131
|
+
*/
|
|
132
|
+
export function resolveDirectives(node) {
|
|
125
133
|
const ng = ngDebug();
|
|
126
134
|
if (!ng?.getDirectives)
|
|
127
135
|
return [];
|
|
@@ -132,11 +140,11 @@ export function resolveDirectiveNames(node) {
|
|
|
132
140
|
catch {
|
|
133
141
|
return []; // node isn't part of a live view
|
|
134
142
|
}
|
|
135
|
-
const
|
|
143
|
+
const found = [];
|
|
136
144
|
for (const directive of directives) {
|
|
137
145
|
const name = nameOf(directive);
|
|
138
146
|
if (name)
|
|
139
|
-
|
|
147
|
+
found.push({ name, instance: directive });
|
|
140
148
|
}
|
|
141
|
-
return
|
|
149
|
+
return found;
|
|
142
150
|
}
|
package/dist/inpage.global.js
CHANGED
|
@@ -34204,6 +34204,9 @@
|
|
|
34204
34204
|
return appComponentFromPath(resolveComponentPath(node), frameworkPrefixes);
|
|
34205
34205
|
}
|
|
34206
34206
|
function resolveDirectiveNames(node) {
|
|
34207
|
+
return resolveDirectives(node).map((d) => d.name);
|
|
34208
|
+
}
|
|
34209
|
+
function resolveDirectives(node) {
|
|
34207
34210
|
const ng = ngDebug();
|
|
34208
34211
|
if (!ng?.getDirectives)
|
|
34209
34212
|
return [];
|
|
@@ -34213,13 +34216,13 @@
|
|
|
34213
34216
|
} catch {
|
|
34214
34217
|
return [];
|
|
34215
34218
|
}
|
|
34216
|
-
const
|
|
34219
|
+
const found = [];
|
|
34217
34220
|
for (const directive of directives) {
|
|
34218
34221
|
const name = nameOf(directive);
|
|
34219
34222
|
if (name)
|
|
34220
|
-
|
|
34223
|
+
found.push({ name, instance: directive });
|
|
34221
34224
|
}
|
|
34222
|
-
return
|
|
34225
|
+
return found;
|
|
34223
34226
|
}
|
|
34224
34227
|
|
|
34225
34228
|
// dist/top-layer.js
|
|
@@ -34439,7 +34442,7 @@
|
|
|
34439
34442
|
function render(findings) {
|
|
34440
34443
|
clear();
|
|
34441
34444
|
for (const finding of findings) {
|
|
34442
|
-
const target = resolveTarget(doc, finding.target);
|
|
34445
|
+
const target = resolveTarget(doc, finding.locator ?? finding.target);
|
|
34443
34446
|
if (!target)
|
|
34444
34447
|
continue;
|
|
34445
34448
|
const box = buildBox(doc, finding);
|
|
@@ -34627,8 +34630,17 @@
|
|
|
34627
34630
|
return false;
|
|
34628
34631
|
return el.getAttribute("aria-hidden") === "true" || el.hasAttribute("data-focus-guard");
|
|
34629
34632
|
}
|
|
34633
|
+
var SCRIPT_TRAP_SELECTOR = "ngb-modal-window, ngb-offcanvas-panel";
|
|
34634
|
+
var TRAP_CANDIDATE_SELECTOR = [
|
|
34635
|
+
'[aria-modal="true"]',
|
|
34636
|
+
'[role="dialog"]',
|
|
34637
|
+
'[role="alertdialog"]',
|
|
34638
|
+
"mat-dialog-container",
|
|
34639
|
+
".cdk-dialog-container",
|
|
34640
|
+
SCRIPT_TRAP_SELECTOR
|
|
34641
|
+
].join(", ");
|
|
34630
34642
|
function sentinelTrappedModal(root, order) {
|
|
34631
|
-
const modals = [...root.querySelectorAll(
|
|
34643
|
+
const modals = [...root.querySelectorAll(TRAP_CANDIDATE_SELECTOR)].reverse();
|
|
34632
34644
|
for (const modal of modals) {
|
|
34633
34645
|
const inside = order.map((el) => modal.contains(el));
|
|
34634
34646
|
const first = inside.indexOf(true);
|
|
@@ -34639,6 +34651,10 @@
|
|
|
34639
34651
|
const after = order[last + 1];
|
|
34640
34652
|
if (before && after && isFocusSentinel(before) && isFocusSentinel(after))
|
|
34641
34653
|
return modal;
|
|
34654
|
+
if (last > first && isFocusSentinel(order[first]) && isFocusSentinel(order[last]))
|
|
34655
|
+
return modal;
|
|
34656
|
+
if (modal.matches(SCRIPT_TRAP_SELECTOR))
|
|
34657
|
+
return modal;
|
|
34642
34658
|
}
|
|
34643
34659
|
return null;
|
|
34644
34660
|
}
|
|
@@ -34822,6 +34838,171 @@
|
|
|
34822
34838
|
return results;
|
|
34823
34839
|
}
|
|
34824
34840
|
|
|
34841
|
+
// dist/keyboard/hover-content.js
|
|
34842
|
+
var empty = (value) => value == null || String(value).trim() === "";
|
|
34843
|
+
var TOOLTIP_LIBRARIES = [
|
|
34844
|
+
// Angular Material
|
|
34845
|
+
{
|
|
34846
|
+
directives: ["MatTooltip"],
|
|
34847
|
+
selector: ".mat-mdc-tooltip-trigger, [mattooltip]",
|
|
34848
|
+
textAttribute: "mattooltip",
|
|
34849
|
+
isOff: (d) => d["disabled"] === true || empty(d["message"])
|
|
34850
|
+
},
|
|
34851
|
+
// PrimeNG
|
|
34852
|
+
{
|
|
34853
|
+
directives: [],
|
|
34854
|
+
genericDirectives: ["Tooltip"],
|
|
34855
|
+
instanceKeys: ["tooltipPosition"],
|
|
34856
|
+
selector: "[ptooltip]",
|
|
34857
|
+
textAttribute: "ptooltip",
|
|
34858
|
+
isOff: (d) => d["tooltipDisabled"] === true || d["disabled"] === true
|
|
34859
|
+
},
|
|
34860
|
+
// ng-bootstrap
|
|
34861
|
+
{
|
|
34862
|
+
directives: ["NgbTooltip"],
|
|
34863
|
+
selector: "[ngbtooltip]",
|
|
34864
|
+
textAttribute: "ngbtooltip",
|
|
34865
|
+
isOff: (d) => d["disableTooltip"] === true || empty(d["ngbTooltip"])
|
|
34866
|
+
},
|
|
34867
|
+
// ngx-bootstrap
|
|
34868
|
+
{
|
|
34869
|
+
directives: [],
|
|
34870
|
+
genericDirectives: ["TooltipDirective"],
|
|
34871
|
+
instanceKeys: ["tooltip"],
|
|
34872
|
+
selector: "[tooltip]",
|
|
34873
|
+
textAttribute: "tooltip",
|
|
34874
|
+
genericMarker: true,
|
|
34875
|
+
isOff: (d) => d["isDisabled"] === true || empty(d["tooltip"])
|
|
34876
|
+
},
|
|
34877
|
+
// ng-zorro
|
|
34878
|
+
{
|
|
34879
|
+
directives: ["NzTooltipDirective"],
|
|
34880
|
+
selector: "[nz-tooltip]",
|
|
34881
|
+
isOff: (d) => "nzTooltipTitle" in d && empty(d["nzTooltipTitle"])
|
|
34882
|
+
},
|
|
34883
|
+
// Taiga UI
|
|
34884
|
+
{ directives: ["TuiHint", "TuiHintDirective", "TuiHintHover"], selector: "[tuihint]", textAttribute: "tuihint" },
|
|
34885
|
+
// @ngneat/helipopper (Tippy.js)
|
|
34886
|
+
{
|
|
34887
|
+
directives: ["TippyDirective"],
|
|
34888
|
+
selector: "[tp]",
|
|
34889
|
+
textAttribute: "tp",
|
|
34890
|
+
genericMarker: true,
|
|
34891
|
+
isOff: (d) => d["tpIsEnabled"] === false
|
|
34892
|
+
},
|
|
34893
|
+
// HTML interest invokers
|
|
34894
|
+
{ directives: [], selector: "[interestfor]" }
|
|
34895
|
+
];
|
|
34896
|
+
var ANY_MARKER = TOOLTIP_LIBRARIES.map((lib) => lib.selector).join(", ");
|
|
34897
|
+
var HOVER_EVENTS = ["mouseenter", "mouseover", "pointerenter", "pointerover"];
|
|
34898
|
+
var ICON_CLASS = /^(mat-icon|material-icons(-[\w-]+)?|material-symbols-\w+|fa-[\w-]+|fa[srlbdt]|fa-solid|fa-regular|bi-[\w-]+|pi-[\w-]+|glyphicon-[\w-]+)$/;
|
|
34899
|
+
function hasTooltip(element) {
|
|
34900
|
+
let marked = false;
|
|
34901
|
+
try {
|
|
34902
|
+
marked = element.matches(ANY_MARKER);
|
|
34903
|
+
} catch {
|
|
34904
|
+
marked = false;
|
|
34905
|
+
}
|
|
34906
|
+
if (marked && element.classList.contains("mat-mdc-tooltip-disabled"))
|
|
34907
|
+
return false;
|
|
34908
|
+
const directives = resolveDirectives(element);
|
|
34909
|
+
for (const lib of TOOLTIP_LIBRARIES) {
|
|
34910
|
+
const found = directives.find((d) => lib.directives.includes(d.name) || lib.genericDirectives?.includes(d.name) && (safeMatches2(element, lib.selector) || (lib.instanceKeys ?? []).some((key) => key in d.instance)));
|
|
34911
|
+
if (found) {
|
|
34912
|
+
if (lib.isOff?.(found.instance) || emptyTextAttribute(element, lib))
|
|
34913
|
+
continue;
|
|
34914
|
+
return true;
|
|
34915
|
+
}
|
|
34916
|
+
if (!marked || !safeMatches2(element, lib.selector))
|
|
34917
|
+
continue;
|
|
34918
|
+
if (directives.length > 0 && lib.directives.length + (lib.genericDirectives?.length ?? 0) > 0)
|
|
34919
|
+
continue;
|
|
34920
|
+
if (lib.genericMarker && globalThis.customElements?.get(element.localName) !== void 0)
|
|
34921
|
+
continue;
|
|
34922
|
+
if (emptyTextAttribute(element, lib))
|
|
34923
|
+
continue;
|
|
34924
|
+
return true;
|
|
34925
|
+
}
|
|
34926
|
+
return false;
|
|
34927
|
+
}
|
|
34928
|
+
function emptyTextAttribute(element, lib) {
|
|
34929
|
+
return !!lib.textAttribute && element.hasAttribute(lib.textAttribute) && empty(element.getAttribute(lib.textAttribute));
|
|
34930
|
+
}
|
|
34931
|
+
function safeMatches2(element, selector) {
|
|
34932
|
+
try {
|
|
34933
|
+
return element.matches(selector);
|
|
34934
|
+
} catch {
|
|
34935
|
+
return false;
|
|
34936
|
+
}
|
|
34937
|
+
}
|
|
34938
|
+
function isIconLike(element) {
|
|
34939
|
+
const tag = element.tagName.toLowerCase();
|
|
34940
|
+
if (tag === "svg" || tag === "img" || tag === "mat-icon")
|
|
34941
|
+
return true;
|
|
34942
|
+
if ([...element.classList].some((c) => ICON_CLASS.test(c)))
|
|
34943
|
+
return true;
|
|
34944
|
+
return (element.textContent ?? "").trim() === "";
|
|
34945
|
+
}
|
|
34946
|
+
function titleRepeatsName(element, title) {
|
|
34947
|
+
const norm = (v) => (v ?? "").trim().toLowerCase();
|
|
34948
|
+
return [element.getAttribute("alt"), element.getAttribute("aria-label")].some((n) => norm(n) === norm(title));
|
|
34949
|
+
}
|
|
34950
|
+
function hoverSignal(element, events) {
|
|
34951
|
+
if (hasTooltip(element))
|
|
34952
|
+
return "tooltip";
|
|
34953
|
+
if (events.some((e) => HOVER_EVENTS.includes(e.split(".")[0])))
|
|
34954
|
+
return "hover-listener";
|
|
34955
|
+
const title = (element.getAttribute("title") ?? "").trim();
|
|
34956
|
+
if (title !== "" && isIconLike(element) && !titleRepeatsName(element, title))
|
|
34957
|
+
return "title";
|
|
34958
|
+
return null;
|
|
34959
|
+
}
|
|
34960
|
+
|
|
34961
|
+
// dist/keyboard/drag-drop.js
|
|
34962
|
+
var DRAG_ITEM_SELECTOR = '.cdk-drop-list .cdk-drag, [draggable="true"]';
|
|
34963
|
+
var DRAG_LIST_SELECTOR = '.cdk-drop-list, [draggable="true"]';
|
|
34964
|
+
var MOVE_NAME = /\b(move|reorder)\b|[↑↓⬆⬇▲▼]|\b(arrow_upward|arrow_downward|keyboard_arrow_up|keyboard_arrow_down)\b|^\s*(up|down|top|bottom|earlier|later)\s*$/i;
|
|
34965
|
+
var CONTROL_SELECTOR = 'button, a[href], [role="button"], [role="menuitem"]';
|
|
34966
|
+
function dragGroups(root, isHidden2) {
|
|
34967
|
+
const groups = /* @__PURE__ */ new Map();
|
|
34968
|
+
for (const item of root.querySelectorAll(DRAG_ITEM_SELECTOR)) {
|
|
34969
|
+
if (item.matches(".cdk-drag-disabled, .cdk-drag-preview, .cdk-drag-placeholder"))
|
|
34970
|
+
continue;
|
|
34971
|
+
if (!item.classList.contains("cdk-drag") && item.parentElement?.closest(".cdk-drag"))
|
|
34972
|
+
continue;
|
|
34973
|
+
const container = item.classList.contains("cdk-drag") ? item.parentElement?.closest(".cdk-drop-list") : item.parentElement;
|
|
34974
|
+
if (!container || container.classList.contains("cdk-drop-list-disabled"))
|
|
34975
|
+
continue;
|
|
34976
|
+
if (isHidden2(item))
|
|
34977
|
+
continue;
|
|
34978
|
+
const items = groups.get(container) ?? [];
|
|
34979
|
+
items.push(item);
|
|
34980
|
+
groups.set(container, items);
|
|
34981
|
+
}
|
|
34982
|
+
return [...groups].map(([container, items]) => ({ container, items, cdk: items[0].classList.contains("cdk-drag") })).filter((group) => group.cdk || group.items.length >= 2);
|
|
34983
|
+
}
|
|
34984
|
+
function dragHandles(item) {
|
|
34985
|
+
const handles = [...item.querySelectorAll(".cdk-drag-handle")].filter((handle) => handle.closest('.cdk-drag, [draggable="true"]') === item);
|
|
34986
|
+
return handles.length > 0 ? handles : [item];
|
|
34987
|
+
}
|
|
34988
|
+
function roughName(element) {
|
|
34989
|
+
const labelledBy = (element.getAttribute("aria-labelledby") ?? "").split(/\s+/).map((id) => id ? element.ownerDocument?.getElementById(id)?.textContent ?? "" : "").join(" ");
|
|
34990
|
+
return [element.getAttribute("aria-label"), labelledBy, element.getAttribute("title"), element.textContent].filter(Boolean).join(" ");
|
|
34991
|
+
}
|
|
34992
|
+
function hasMoveControl(container, isTabbable2) {
|
|
34993
|
+
const siblings = [...container.parentElement?.children ?? []].filter((el) => el !== container && !el.matches(DRAG_LIST_SELECTOR) && !el.querySelector(DRAG_LIST_SELECTOR));
|
|
34994
|
+
for (const scope of [container, ...siblings]) {
|
|
34995
|
+
const controls = [...scope.matches(CONTROL_SELECTOR) ? [scope] : [], ...scope.querySelectorAll(CONTROL_SELECTOR)];
|
|
34996
|
+
for (const control of controls) {
|
|
34997
|
+
if (control.closest(".cdk-drag-handle"))
|
|
34998
|
+
continue;
|
|
34999
|
+
if (MOVE_NAME.test(roughName(control)) && isTabbable2(control))
|
|
35000
|
+
return true;
|
|
35001
|
+
}
|
|
35002
|
+
}
|
|
35003
|
+
return false;
|
|
35004
|
+
}
|
|
35005
|
+
|
|
34825
35006
|
// dist/keyboard/keyboard-scan.js
|
|
34826
35007
|
var INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
34827
35008
|
"button",
|
|
@@ -34845,6 +35026,10 @@
|
|
|
34845
35026
|
function hasKeyEvent(events) {
|
|
34846
35027
|
return events.some((e) => KEY_EVENTS.includes(e.split(".")[0]));
|
|
34847
35028
|
}
|
|
35029
|
+
function hasTabindex(element) {
|
|
35030
|
+
const tabindex = element.getAttribute("tabindex");
|
|
35031
|
+
return tabindex !== null && !Number.isNaN(Number.parseInt(tabindex, 10));
|
|
35032
|
+
}
|
|
34848
35033
|
var COMPOSITE_SELECTOR = ["tablist", "toolbar", "menu", "menubar", "radiogroup", "listbox", "tree", "treegrid", "grid"].map((role) => `[role="${role}"]`).join(",");
|
|
34849
35034
|
function reachedWithinWidget(element, isVisible, keyCache = /* @__PURE__ */ new Map(), sharedCache = /* @__PURE__ */ new Map()) {
|
|
34850
35035
|
const widget = element.parentElement?.closest(COMPOSITE_SELECTOR);
|
|
@@ -34945,6 +35130,13 @@
|
|
|
34945
35130
|
return false;
|
|
34946
35131
|
}
|
|
34947
35132
|
}
|
|
35133
|
+
function hasTabbableOrFlaggedAncestor(element, flagged, isVisible) {
|
|
35134
|
+
for (let el = element.parentElement; el; el = el.parentElement) {
|
|
35135
|
+
if (flagged.has(el) || isTabbable(el, isVisible))
|
|
35136
|
+
return true;
|
|
35137
|
+
}
|
|
35138
|
+
return false;
|
|
35139
|
+
}
|
|
34948
35140
|
var ITEM_SELECTOR = [...INTERACTIVE_ROLES].map((role) => `[role="${role}"]`).join(",");
|
|
34949
35141
|
function partOfKeyboardOperatedWidget(element, isVisible, keyCache, sharedCache) {
|
|
34950
35142
|
const item = element.parentElement?.closest(ITEM_SELECTOR);
|
|
@@ -34967,6 +35159,38 @@
|
|
|
34967
35159
|
const classes = (element.getAttribute("class") ?? "").trim().split(/\s+/).filter(Boolean).slice(0, 2);
|
|
34968
35160
|
return classes.length ? `${tag}.${classes.join(".")}` : tag;
|
|
34969
35161
|
}
|
|
35162
|
+
function uniqueLocator(element) {
|
|
35163
|
+
const doc = element.ownerDocument;
|
|
35164
|
+
const escape = globalThis.CSS?.escape;
|
|
35165
|
+
if (!doc || typeof escape !== "function" || element.getRootNode() !== doc)
|
|
35166
|
+
return void 0;
|
|
35167
|
+
const count = (selector) => {
|
|
35168
|
+
try {
|
|
35169
|
+
return doc.querySelectorAll(selector).length;
|
|
35170
|
+
} catch {
|
|
35171
|
+
return 0;
|
|
35172
|
+
}
|
|
35173
|
+
};
|
|
35174
|
+
const short = shortSelector(element);
|
|
35175
|
+
if (count(short) === 1 && doc.querySelector(short) === element)
|
|
35176
|
+
return void 0;
|
|
35177
|
+
const step = (el) => {
|
|
35178
|
+
if (el.id && count(`#${escape(el.id)}`) === 1)
|
|
35179
|
+
return { text: `#${escape(el.id)}`, anchored: true };
|
|
35180
|
+
const classes = [...el.classList].slice(0, 2).map((c) => `.${escape(c)}`).join("");
|
|
35181
|
+
const index = el.parentElement ? [...el.parentElement.children].indexOf(el) + 1 : 1;
|
|
35182
|
+
return { text: `${el.tagName.toLowerCase()}${classes}:nth-child(${index})`, anchored: false };
|
|
35183
|
+
};
|
|
35184
|
+
const steps = [];
|
|
35185
|
+
for (let el = element; el && el !== doc.documentElement; el = el.parentElement) {
|
|
35186
|
+
const { text, anchored } = step(el);
|
|
35187
|
+
steps.unshift(text);
|
|
35188
|
+
const selector = steps.join(" > ");
|
|
35189
|
+
if (anchored || count(selector) === 1)
|
|
35190
|
+
return selector;
|
|
35191
|
+
}
|
|
35192
|
+
return void 0;
|
|
35193
|
+
}
|
|
34970
35194
|
function shortHtml(element) {
|
|
34971
35195
|
const html = element.outerHTML ?? "";
|
|
34972
35196
|
return html.length > 160 ? `${html.slice(0, 159)}\u2026` : html;
|
|
@@ -34977,6 +35201,29 @@
|
|
|
34977
35201
|
const findings = [];
|
|
34978
35202
|
const keyCache = /* @__PURE__ */ new Map();
|
|
34979
35203
|
const sharedCache = /* @__PURE__ */ new Map();
|
|
35204
|
+
const unreachable = /* @__PURE__ */ new Set();
|
|
35205
|
+
const listenerEvents = /* @__PURE__ */ new Map();
|
|
35206
|
+
const eventsOf = (el) => {
|
|
35207
|
+
let events = listenerEvents.get(el);
|
|
35208
|
+
if (!events)
|
|
35209
|
+
listenerEvents.set(el, events = resolveListenerEvents(el));
|
|
35210
|
+
return events;
|
|
35211
|
+
};
|
|
35212
|
+
const hoverFinding = (element, signal) => {
|
|
35213
|
+
const url = `${RULE_DOCS}/hover-only-content`;
|
|
35214
|
+
const only = element.children.length === 1 ? element.children[0] : null;
|
|
35215
|
+
const disabled = isNativelyFocusable(element) && isDisabled(element) ? element : signal === "tooltip" ? [...element.querySelectorAll("button, input, select, textarea")].find(isDisabled) : only && isNativelyFocusable(only) && isDisabled(only) ? only : void 0;
|
|
35216
|
+
if (disabled) {
|
|
35217
|
+
return make(element, "ngbr/hover-only-content", signal === "tooltip" ? "moderate" : "minor", `Keyboard users may not see this disabled control's hover content: a disabled control can't take focus, so its tooltip only opens for the mouse. Use aria-disabled="true" instead of disabled, or show the reason as text. Heuristic \u2014 verify manually.`, url);
|
|
35218
|
+
}
|
|
35219
|
+
if (signal === "title") {
|
|
35220
|
+
return make(element, "ngbr/hover-only-content", "minor", `Only mouse users see this icon's title: Tab doesn't reach the icon, so keyboard users can't show its title. Show the text on the page, or put the icon in a focusable control with a visible label or tooltip. Heuristic \u2014 verify manually.`, url);
|
|
35221
|
+
}
|
|
35222
|
+
if (signal === "hover-listener") {
|
|
35223
|
+
return make(element, "ngbr/hover-only-content", "minor", `Keyboard users may not see what this shows on hover: it listens for the mouse moving over it, but Tab doesn't reach it. If it shows content, make it focusable and show the content on focus too, or show it on the page. Heuristic \u2014 verify manually.`, url);
|
|
35224
|
+
}
|
|
35225
|
+
return make(element, "ngbr/hover-only-content", "moderate", `Keyboard users may not see this tooltip: it opens on hover, but Tab doesn't reach it. Make it focusable (a <button>, or tabindex="0") and check the tooltip opens on focus, or show the text on the page. Heuristic \u2014 verify manually.`, url);
|
|
35226
|
+
};
|
|
34980
35227
|
const make = (element, id, impact, help, helpUrl) => {
|
|
34981
35228
|
const componentPath = resolveComponentPath(element);
|
|
34982
35229
|
return {
|
|
@@ -34988,6 +35235,7 @@
|
|
|
34988
35235
|
componentPath,
|
|
34989
35236
|
directives: resolveDirectiveNames(element),
|
|
34990
35237
|
target: shortSelector(element),
|
|
35238
|
+
locator: uniqueLocator(element),
|
|
34991
35239
|
html: shortHtml(element)
|
|
34992
35240
|
};
|
|
34993
35241
|
};
|
|
@@ -34999,7 +35247,7 @@
|
|
|
34999
35247
|
if (isNativelyFocusable(element))
|
|
35000
35248
|
continue;
|
|
35001
35249
|
const role = element.getAttribute("role")?.toLowerCase() ?? "";
|
|
35002
|
-
const events =
|
|
35250
|
+
const events = eventsOf(element);
|
|
35003
35251
|
const hasClick = events.includes("click");
|
|
35004
35252
|
const interactiveByRole = INTERACTIVE_ROLES.has(role);
|
|
35005
35253
|
if (!hasClick && !interactiveByRole)
|
|
@@ -35017,9 +35265,11 @@
|
|
|
35017
35265
|
continue;
|
|
35018
35266
|
if (within === "no-keys") {
|
|
35019
35267
|
findings.push(make(element, "ngbr/unreachable-control", "moderate", `Keyboard users may not be able to reach this item: it has role="${role}" and is out of the tab order, like a roving-tabindex item, but nothing in or around its widget handles keys, so arrow keys may not move to it. Handle the arrow keys, or use aria-activedescendant. Heuristic \u2014 verify manually.`, `${RULE_DOCS}/unreachable-control`));
|
|
35268
|
+
unreachable.add(element);
|
|
35020
35269
|
continue;
|
|
35021
35270
|
}
|
|
35022
35271
|
const reason = interactiveByRole ? `has role="${role}"` : "has a click handler";
|
|
35272
|
+
unreachable.add(element);
|
|
35023
35273
|
findings.push(make(element, "ngbr/unreachable-control", "serious", `Keyboard users can't reach this control: it ${reason}, but it isn't a native control and has no tabindex="0", so Tab skips it. Use a <button> or <a href>, or add tabindex="0" and Enter/Space handling.`, `${RULE_DOCS}/unreachable-control`));
|
|
35024
35274
|
continue;
|
|
35025
35275
|
}
|
|
@@ -35028,6 +35278,71 @@
|
|
|
35028
35278
|
findings.push(make(element, "ngbr/click-without-key", "moderate", `Keyboard users may not be able to activate this: Tab reaches it, but it only listens for click, and Enter and Space don't fire click on a non-native element. Use a <button>, or handle Enter and Space too. Heuristic \u2014 verify manually.`, `${RULE_DOCS}/click-without-key`));
|
|
35029
35279
|
}
|
|
35030
35280
|
}
|
|
35281
|
+
const hoverFlagged = new Set(unreachable);
|
|
35282
|
+
for (const element of root.querySelectorAll("*")) {
|
|
35283
|
+
if (modal && !modal.contains(element))
|
|
35284
|
+
continue;
|
|
35285
|
+
if (hoverFlagged.has(element) || element.closest(OVERLAY_EXCLUDE_SELECTOR))
|
|
35286
|
+
continue;
|
|
35287
|
+
const signal = hoverSignal(element, eventsOf(element));
|
|
35288
|
+
if (!signal)
|
|
35289
|
+
continue;
|
|
35290
|
+
if (isTabbable(element, isVisible) || isHidden(element, isVisible))
|
|
35291
|
+
continue;
|
|
35292
|
+
if (hasTabbableDescendant(element, isVisible))
|
|
35293
|
+
continue;
|
|
35294
|
+
if (hasTabbableOrFlaggedAncestor(element, hoverFlagged, isVisible))
|
|
35295
|
+
continue;
|
|
35296
|
+
if (reachedWithinWidget(element, isVisible, keyCache, sharedCache) === "reached")
|
|
35297
|
+
continue;
|
|
35298
|
+
hoverFlagged.add(element);
|
|
35299
|
+
findings.push(hoverFinding(element, signal));
|
|
35300
|
+
}
|
|
35301
|
+
const groups = dragGroups(root, (el) => isHidden(el, isVisible));
|
|
35302
|
+
const startsOf = (container, items) => [
|
|
35303
|
+
.../* @__PURE__ */ new Set([container, ...items.flatMap(dragHandles)])
|
|
35304
|
+
];
|
|
35305
|
+
const anyTabStop = groups.some(({ container, items }) => startsOf(container, items).some((el) => isTabbable(el, isVisible)));
|
|
35306
|
+
for (const { container, items, cdk } of groups) {
|
|
35307
|
+
if (modal && !modal.contains(container))
|
|
35308
|
+
continue;
|
|
35309
|
+
if (container.closest(OVERLAY_EXCLUDE_SELECTOR))
|
|
35310
|
+
continue;
|
|
35311
|
+
if (hasMoveControl(container, (el) => isTabbable(el, isVisible)))
|
|
35312
|
+
continue;
|
|
35313
|
+
const starts = startsOf(container, items);
|
|
35314
|
+
const reachable = starts.filter((el) => isTabbable(el, isVisible) || anyTabStop && hasTabindex(el) && !isDisabled(el) && !isHidden(el, isVisible));
|
|
35315
|
+
const url = `${RULE_DOCS}/drag-without-keyboard`;
|
|
35316
|
+
const count = items.length === 1 ? "1 item here moves" : `${items.length} items here move`;
|
|
35317
|
+
const fix = `Add buttons that move an item (Move up, Move down), or make each drag handle a button that moves its item with the arrow keys and announces the new position. Buttons also help people who can't drag with a mouse.`;
|
|
35318
|
+
if (reachable.length === 0) {
|
|
35319
|
+
findings.push(make(
|
|
35320
|
+
container,
|
|
35321
|
+
"ngbr/drag-without-keyboard",
|
|
35322
|
+
// Native draggable="true" is weaker evidence of a list to reorder than CDK's.
|
|
35323
|
+
cdk ? "serious" : "moderate",
|
|
35324
|
+
`Keyboard users can't move these items: ${count} by drag and drop, but Tab doesn't reach a drag handle and there's no other control to move them. ${fix} Heuristic \u2014 verify manually.`,
|
|
35325
|
+
url
|
|
35326
|
+
));
|
|
35327
|
+
continue;
|
|
35328
|
+
}
|
|
35329
|
+
if (!listenersVisible())
|
|
35330
|
+
continue;
|
|
35331
|
+
const ng = ngDebug();
|
|
35332
|
+
const keyed = (start) => {
|
|
35333
|
+
for (let el = start; el && el !== el.ownerDocument?.body; el = el.parentElement) {
|
|
35334
|
+
if (hasKeyEvent(eventsOf(el)))
|
|
35335
|
+
return true;
|
|
35336
|
+
if (!container.contains(el) && isComponentHost(el, ng))
|
|
35337
|
+
break;
|
|
35338
|
+
}
|
|
35339
|
+
return false;
|
|
35340
|
+
};
|
|
35341
|
+
const handlesKeys2 = reachable.some(keyed);
|
|
35342
|
+
if (handlesKeys2)
|
|
35343
|
+
continue;
|
|
35344
|
+
findings.push(make(container, "ngbr/drag-without-keyboard", "moderate", `Keyboard users may not be able to move these items: ${count} by drag and drop, and the keyboard can reach their drag handles, but nothing on them handles keys. ${fix} Heuristic \u2014 verify manually.`, url));
|
|
35345
|
+
}
|
|
35031
35346
|
for (const modal2 of findUncontainedModals(root, { frameworkPrefixes: prefixes, isVisible })) {
|
|
35032
35347
|
findings.push(make(modal2.element, "ngbr/modal-focus-not-contained", "moderate", `Keyboard users can Tab out of this modal: it has aria-modal="true", but ${modal2.outsideCount} control(s) outside it can still be reached with Tab. Open it with <dialog>.showModal(), make the rest of the page inert, or trap focus. Heuristic \u2014 verify manually.`, `${RULE_DOCS}/modal-focus-not-contained`));
|
|
35033
35348
|
}
|
|
@@ -35073,7 +35388,7 @@
|
|
|
35073
35388
|
}
|
|
35074
35389
|
function containedByOpenModal(elements) {
|
|
35075
35390
|
const modalOf = (el) => {
|
|
35076
|
-
const aria = el.closest('[aria-modal="true"]');
|
|
35391
|
+
const aria = el.closest('[aria-modal="true"], mat-dialog-container, .cdk-dialog-container');
|
|
35077
35392
|
if (aria)
|
|
35078
35393
|
return aria;
|
|
35079
35394
|
try {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What marks a list whose items move by drag and drop, and what counts as a
|
|
3
|
+
* keyboard way to move them. The keyboard scan reports such a list when it finds
|
|
4
|
+
* no keyboard way (`ngbr/drag-without-keyboard`): Angular CDK drag-drop has no
|
|
5
|
+
* keyboard support of its own, so a CDK list is mouse-only unless the app adds it.
|
|
6
|
+
*
|
|
7
|
+
* Drag items are recognised by DOM markers that are there in production builds
|
|
8
|
+
* too: the `cdk-drag` class that `cdkDrag` puts on its host (only inside a
|
|
9
|
+
* `cdk-drop-list`; a free-standing `cdkDrag`, such as a draggable dialog title,
|
|
10
|
+
* moves something around the screen and is left out), and an explicit
|
|
11
|
+
* `draggable="true"` (native HTML drag and drop, ngx-drag-drop's `dndDraggable`).
|
|
12
|
+
*/
|
|
13
|
+
/** A list of drag items under one container. */
|
|
14
|
+
export interface DragGroup {
|
|
15
|
+
/** The drop list, or the items' parent for native drag and drop. */
|
|
16
|
+
container: Element;
|
|
17
|
+
/** The items that can be dragged now (not disabled, not hidden). */
|
|
18
|
+
items: Element[];
|
|
19
|
+
/** True for CDK drag and drop; false for native `draggable="true"`. */
|
|
20
|
+
cdk: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The drag lists in `root`, one per container. CDK items group by their
|
|
24
|
+
* `cdk-drop-list`; native ones by their parent, and only when there are at least
|
|
25
|
+
* two (one draggable on its own is more often an image or file chip to drag
|
|
26
|
+
* out of the page than a list to reorder). A disabled list or item (CDK's
|
|
27
|
+
* `cdk-drop-list-disabled` / `cdk-drag-disabled`) and CDK's drag preview and
|
|
28
|
+
* placeholder are left out.
|
|
29
|
+
*/
|
|
30
|
+
export declare function dragGroups(root: ParentNode, isHidden: (el: Element) => boolean): DragGroup[];
|
|
31
|
+
/**
|
|
32
|
+
* Where a keyboard user would start a move for `item`: its CDK drag handles that
|
|
33
|
+
* belong to it (not to a nested drag item), or the item itself.
|
|
34
|
+
*/
|
|
35
|
+
export declare function dragHandles(item: Element): Element[];
|
|
36
|
+
/**
|
|
37
|
+
* True when there's a control near the list whose name says it moves an item
|
|
38
|
+
* ("Move up", "↓", an `arrow_upward` icon): in the list, or in an element next
|
|
39
|
+
* to it such as a toolbar above it. A sibling that holds another drag list is
|
|
40
|
+
* left out, so one list's Move buttons don't vouch for the list beside it. A
|
|
41
|
+
* drag handle doesn't count, even one named "Reorder": whether it works from the
|
|
42
|
+
* keyboard depends on its key handling, which the scan checks separately.
|
|
43
|
+
* `isTabbable` decides whether the keyboard can reach it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function hasMoveControl(container: Element, isTabbable: (el: Element) => boolean): boolean;
|