@surea11y/core 1.4.0 → 1.5.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +88 -7
  2. package/README.md +19 -3
  3. package/bin/surea11y-core.js +0 -0
  4. package/docs/API_STABILITY.md +2 -2
  5. package/docs/ARIA_DEPRECATION.md +95 -0
  6. package/docs/ENGINE_OPTIONS.md +14 -10
  7. package/docs/I18N.md +176 -20
  8. package/docs/INTEGRATION.md +28 -6
  9. package/docs/LIMITATIONS.md +1 -1
  10. package/docs/OUTPUT_SCHEMA.md +13 -3
  11. package/docs/REPORT.md +2 -0
  12. package/docs/RULE_AUTHORING.md +53 -0
  13. package/docs/RULE_CATALOG.md +6 -6
  14. package/docs/TROUBLESHOOTING.md +2 -2
  15. package/package.json +8 -1
  16. package/src/checks/automatic/aria-allowed-attr.js +661 -99
  17. package/src/checks/automatic/aria-allowed-role.js +14 -16
  18. package/src/checks/automatic/aria-braille-equivalent.js +17 -19
  19. package/src/checks/automatic/aria-conditional-attr.js +17 -19
  20. package/src/checks/automatic/aria-deprecated-role.js +122 -41
  21. package/src/checks/automatic/aria-hidden-body.js +2 -9
  22. package/src/checks/automatic/aria-hidden-focus.js +99 -18
  23. package/src/checks/automatic/aria-prohibited-attr.js +54 -55
  24. package/src/checks/automatic/aria-prohibited-children.js +26 -26
  25. package/src/checks/automatic/aria-required-attr.js +14 -17
  26. package/src/checks/automatic/aria-required-children.js +17 -20
  27. package/src/checks/automatic/aria-required-parent.js +17 -20
  28. package/src/checks/automatic/aria-roles-valid.js +66 -27
  29. package/src/checks/automatic/aria-valid-attr-value.js +18 -21
  30. package/src/checks/automatic/aria-valid-attr.js +14 -17
  31. package/src/checks/automatic/autocomplete-valid.js +52 -18
  32. package/src/checks/automatic/avoid-inline-spacing.js +192 -34
  33. package/src/checks/automatic/binary-control-name-present.js +30 -24
  34. package/src/checks/automatic/button-name-present.js +73 -45
  35. package/src/checks/automatic/canvas-text-alternative-present.js +15 -8
  36. package/src/checks/automatic/combobox-name-present.js +23 -18
  37. package/src/checks/automatic/css-orientation-lock.js +22 -22
  38. package/src/checks/automatic/definition-list-children-valid.js +18 -21
  39. package/src/checks/automatic/deprecated-elements-not-used.js +14 -16
  40. package/src/checks/automatic/dialog-name-present.js +24 -19
  41. package/src/checks/automatic/dlitem-parent-valid.js +15 -17
  42. package/src/checks/automatic/duplicate-id-aria.js +45 -37
  43. package/src/checks/automatic/form-control-programmatic-label-present.js +48 -4
  44. package/src/checks/automatic/form-control-single-label.js +109 -43
  45. package/src/checks/automatic/html-xml-lang-mismatch.js +2 -9
  46. package/src/checks/automatic/iframe-focusable-content.js +29 -31
  47. package/src/checks/automatic/iframe-name-present.js +15 -17
  48. package/src/checks/automatic/iframe-title-unique.js +18 -23
  49. package/src/checks/automatic/img-alt-present.js +16 -9
  50. package/src/checks/automatic/input-image-alt-present.js +99 -48
  51. package/src/checks/automatic/label-in-name.js +102 -33
  52. package/src/checks/automatic/language-page-present.js +5 -1
  53. package/src/checks/automatic/link-in-text-block.js +19 -21
  54. package/src/checks/automatic/link-name-present.js +75 -47
  55. package/src/checks/automatic/list-children-valid.js +15 -17
  56. package/src/checks/automatic/listbox-name-present.js +23 -18
  57. package/src/checks/automatic/listitem-parent-valid.js +14 -17
  58. package/src/checks/automatic/menuitem-name-present.js +24 -19
  59. package/src/checks/automatic/meta-refresh-no-exceptions.js +44 -18
  60. package/src/checks/automatic/meta-refresh-timing-absent.js +44 -21
  61. package/src/checks/automatic/meta-viewport-zoom-enabled.js +51 -32
  62. package/src/checks/automatic/meter-name-present.js +24 -19
  63. package/src/checks/automatic/nested-interactive-controls-absent.js +179 -51
  64. package/src/checks/automatic/object-text-alternative-present.js +14 -7
  65. package/src/checks/automatic/option-name-present.js +24 -19
  66. package/src/checks/automatic/progressbar-name-present.js +27 -22
  67. package/src/checks/automatic/searchbox-name-present.js +27 -18
  68. package/src/checks/automatic/server-side-image-map-absent.js +15 -18
  69. package/src/checks/automatic/slider-name-present.js +26 -19
  70. package/src/checks/automatic/spinbutton-name-present.js +27 -18
  71. package/src/checks/automatic/summary-name-present.js +24 -19
  72. package/src/checks/automatic/tab-name-present.js +24 -19
  73. package/src/checks/automatic/table-headers-attr-valid.js +15 -17
  74. package/src/checks/automatic/table-th-has-data-cells.js +82 -25
  75. package/src/checks/automatic/target-size-minimum.js +104 -81
  76. package/src/checks/automatic/td-has-header.js +15 -20
  77. package/src/checks/automatic/textbox-name-present.js +23 -18
  78. package/src/checks/automatic/tooltip-name-present.js +24 -19
  79. package/src/checks/automatic/treeitem-name-present.js +24 -19
  80. package/src/checks/automatic/valid-lang.js +31 -20
  81. package/src/checks/manual/accesskeys-manual.js +18 -19
  82. package/src/checks/manual/aria-checked-state-mismatch-manual.js +19 -22
  83. package/src/checks/{automatic/bypass-blocks-present.js → manual/bypass-blocks-present-manual.js} +98 -44
  84. package/src/checks/manual/empty-heading-manual.js +15 -17
  85. package/src/checks/manual/empty-table-header-manual.js +27 -30
  86. package/src/checks/manual/form-control-programmatic-label-quality-manual.js +2 -9
  87. package/src/checks/manual/heading-order-manual.js +17 -22
  88. package/src/checks/manual/image-redundant-alt-manual.js +14 -17
  89. package/src/checks/manual/input-image-alt-decorative-manual.js +24 -0
  90. package/src/checks/manual/label-title-only-manual.js +15 -17
  91. package/src/checks/manual/landmark-banner-is-top-level-manual.js +25 -39
  92. package/src/checks/manual/landmark-contentinfo-is-top-level-manual.js +21 -27
  93. package/src/checks/manual/landmark-main-is-top-level-manual.js +14 -17
  94. package/src/checks/manual/landmark-no-duplicate-banner-manual.js +2 -7
  95. package/src/checks/manual/landmark-no-duplicate-contentinfo-manual.js +2 -7
  96. package/src/checks/manual/landmark-no-duplicate-main-manual.js +2 -7
  97. package/src/checks/manual/landmark-one-main-manual.js +2 -9
  98. package/src/checks/manual/landmark-unique-manual.js +22 -27
  99. package/src/checks/manual/link-name-quality-manual.js +15 -17
  100. package/src/checks/manual/meta-viewport-large-manual.js +14 -17
  101. package/src/checks/manual/mouse-only-event-handlers-manual.js +17 -19
  102. package/src/checks/manual/page-has-heading-one-manual.js +2 -9
  103. package/src/checks/manual/presentation-role-conflict-manual.js +19 -21
  104. package/src/checks/manual/region-manual.js +13 -6
  105. package/src/checks/manual/scope-attr-valid-manual.js +14 -17
  106. package/src/checks/manual/skip-link-manual.js +39 -47
  107. package/src/checks/manual/tabindex-manual.js +14 -17
  108. package/src/checks/manual/table-duplicate-name-manual.js +14 -17
  109. package/src/core.js +8818 -4330
  110. package/src/report.js +14 -0
  111. package/src/sarif.js +2 -2
  112. package/surea11y.browser.js +4023 -3911
  113. package/surea11y.i18n.de.js +22 -0
  114. package/surea11y.i18n.es.js +22 -0
  115. package/surea11y.i18n.fr.js +22 -0
@@ -9,17 +9,19 @@
9
9
  * @standard WCAG 2.2
10
10
  * @sc 1.4.4
11
11
  * @applicability
12
- * Applies to <meta name="viewport"> elements that carry a non-empty
13
- * content attribute.
12
+ * Applies to <meta name="viewport"> elements whose content attribute sets
13
+ * maximum-scale or user-scalable. Content setting neither cannot restrict
14
+ * zoom.
14
15
  * @expectation
15
- * The content attribute does not set user-scalable to "no"/"0", and does
16
- * not set maximum-scale below 2 (200%). Either disables the user's
17
- * ability to zoom text to at least 200%, which WCAG 1.4.4 (Resize Text)
18
- * requires be possible.
16
+ * user-scalable is absent, yes, device-width, device-height, or a number
17
+ * outside the range -1 to 1; and maximum-scale is absent, device-width,
18
+ * device-height, negative, or 2 or more. Anything else stops the user
19
+ * zooming text to 200%, which WCAG 1.4.4 (Resize Text) requires.
19
20
  * @implementation-notes
20
- * - Malformed/unparseable maximum-scale values are ignored (not flagged) —
21
- * this rule only reports a clearly-detected zoom restriction, matching
22
- * this engine's no-false-positives policy.
21
+ * - An unparseable value counts as a restriction, because CSS Device
22
+ * Adaptation translates it to 0: maximum-scale=yes disables zoom exactly
23
+ * as maximum-scale=0 does. A negative maximum-scale is out of range and
24
+ * dropped by the browser, so it restricts nothing and passes.
23
25
  */
24
26
 
25
27
  const id = 'meta-viewport-zoom-enabled';
@@ -89,43 +91,60 @@ function runInPage(ctx) {
89
91
  const raw = String(el.getAttribute('content') || '').trim();
90
92
  if (!raw) continue;
91
93
 
92
- applicableCount += 1;
93
-
94
94
  const parsed = parseContent(raw);
95
+
96
+ // ACT b4f0c3 applies only when content carries maximum-scale or
97
+ // user-scalable; content that sets neither cannot restrict zoom.
98
+ if (parsed['user-scalable'] === undefined && parsed['maximum-scale'] === undefined) continue;
99
+
100
+ applicableCount += 1;
95
101
  const reasons = [];
96
102
 
103
+ // CSS Device Adaptation translates an unparseable value to 0, so
104
+ // user-scalable=invalid and maximum-scale=yes disable zoom just as
105
+ // user-scalable=no does. A negative maximum-scale is out of range and
106
+ // dropped instead, which is why it does not restrict anything.
97
107
  const userScalable = parsed['user-scalable'];
98
- if (userScalable === 'no' || userScalable === '0') {
99
- reasons.push('user-scalable=' + userScalable);
108
+ if (
109
+ userScalable !== undefined &&
110
+ userScalable !== 'yes' &&
111
+ userScalable !== 'device-width' &&
112
+ userScalable !== 'device-height'
113
+ ) {
114
+ const scale = parseFloat(userScalable);
115
+ if (Number.isNaN(scale) || (scale > -1 && scale < 1)) {
116
+ reasons.push('user-scalable=' + userScalable);
117
+ }
100
118
  }
101
119
 
102
120
  const maxScaleRaw = parsed['maximum-scale'];
103
- if (maxScaleRaw !== undefined) {
121
+ if (
122
+ maxScaleRaw !== undefined &&
123
+ maxScaleRaw !== 'device-width' &&
124
+ maxScaleRaw !== 'device-height'
125
+ ) {
104
126
  const maxScale = parseFloat(maxScaleRaw);
105
- if (!Number.isNaN(maxScale) && maxScale < 2) {
127
+ if (Number.isNaN(maxScale) || (maxScale >= 0 && maxScale < 2)) {
106
128
  reasons.push('maximum-scale=' + maxScaleRaw);
107
129
  }
108
130
  }
109
131
 
110
132
  if (!reasons.length) continue;
111
133
 
112
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
113
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
114
-
115
- occurrences.push({
116
- selector: stableSelector,
117
- html,
118
- summary: 'This viewport meta tag restricts the user’s ability to zoom.',
119
- hint: 'Remove user-scalable=no and any maximum-scale below 2 from the viewport meta content.',
120
- i18n: {
121
- summaryKey: 'metaViewportZoomEnabled_summary_fail',
122
- hintKey: 'metaViewportZoomEnabled_hint_fail',
123
- params: { reasons: reasons.join(', ') }
124
- },
125
- data: {
126
- details: { reasonCode: 'VIEWPORT_ZOOM_RESTRICTED', reasons }
127
- }
128
- });
134
+ occurrences.push(
135
+ helpers.reportOccurrence(el, {
136
+ summary: 'This viewport meta tag restricts the user’s ability to zoom.',
137
+ hint: 'Remove user-scalable=no and any maximum-scale below 2 from the viewport meta content.',
138
+ i18n: {
139
+ summaryKey: 'metaViewportZoomEnabled_summary_fail',
140
+ hintKey: 'metaViewportZoomEnabled_hint_fail',
141
+ params: { reasons: reasons.join(', ') }
142
+ },
143
+ data: {
144
+ details: { reasonCode: 'VIEWPORT_ZOOM_RESTRICTED', reasons }
145
+ }
146
+ })
147
+ );
129
148
  }
130
149
 
131
150
  if (applicableCount === 0) {
@@ -67,9 +67,16 @@ function runInPage(ctx) {
67
67
  return '';
68
68
  }
69
69
 
70
+ // Naming rules apply only to elements included in the accessibility tree
71
+ // (ACT c487ae and siblings), which excludes focusable aria-hidden content.
72
+ // aria-hidden-focus (ACT 6cfa84) covers that markup instead.
70
73
  function isEligibleAcc(helpers, el, ctx) {
71
74
  const fn =
72
- helpers && typeof helpers.isAccTreeEligible === 'function' ? helpers.isAccTreeEligible : null;
75
+ helpers && typeof helpers.isIncludedInAccessibilityTree === 'function'
76
+ ? helpers.isIncludedInAccessibilityTree
77
+ : helpers && typeof helpers.isAccTreeEligible === 'function'
78
+ ? helpers.isAccTreeEligible
79
+ : null;
73
80
  if (!fn) return true;
74
81
  try {
75
82
  const r = fn(el, ctx);
@@ -126,24 +133,22 @@ function runInPage(ctx) {
126
133
  }
127
134
  })()
128
135
  : null;
129
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
130
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
131
-
132
- occurrences.push({
133
- selector: stableSelector,
134
- html,
135
- summary: 'This meter has no accessible name.',
136
- hint: "Provide aria-label, aria-labelledby, or a title attribute — visible text content is not exposed as this meter's accessible name.",
137
- i18n: {
138
- summaryKey: 'meterNamePresent_summary_fail',
139
- hintKey: 'meterNamePresent_hint_fail',
140
- params: {}
141
- },
142
- data: {
143
- details: { reasonCode: 'name_missing', controlType: 'meter', methodTried: res.method },
144
- visibilityFilter: eligInfo || { targetSet: 'acc', accEligible: null, reasons: [] }
145
- }
146
- });
136
+
137
+ occurrences.push(
138
+ helpers.reportOccurrence(el, {
139
+ summary: 'This meter has no accessible name.',
140
+ hint: "Provide aria-label, aria-labelledby, or a title attribute — visible text content is not exposed as this meter's accessible name.",
141
+ i18n: {
142
+ summaryKey: 'meterNamePresent_summary_fail',
143
+ hintKey: 'meterNamePresent_hint_fail',
144
+ params: {}
145
+ },
146
+ data: {
147
+ details: { reasonCode: 'name_missing', controlType: 'meter', methodTried: res.method },
148
+ visibilityFilter: eligInfo || { targetSet: 'acc', accEligible: null, reasons: [] }
149
+ }
150
+ })
151
+ );
147
152
  }
148
153
 
149
154
  if (applicableCount === 0) {
@@ -13,22 +13,48 @@
13
13
  * a[href], button, input (not hidden), select, textarea; or an explicit
14
14
  * ARIA widget role: button, link, checkbox, radio, switch, tab, textbox,
15
15
  * combobox, listbox, menuitem, menuitemcheckbox, menuitemradio, option,
16
- * slider, spinbutton, searchbox, treeitem).
16
+ * slider, spinbutton, searchbox, treeitem). The container is applicable
17
+ * regardless of whether it is itself focusable — focusability is only
18
+ * used to decide whether a *descendant* nests an interactive control.
17
19
  * @expectation
18
- * The element does not contain, as a descendant, another element from
19
- * that same interactive-control set (e.g. a <button> wrapping a
20
- * <select>, or a link containing a checkbox). Nested interactive
21
- * controls are not reliably announced or operable via assistive
22
- * technology — activating the outer control and the inner one become
23
- * ambiguous, and some AT only exposes one of the two.
20
+ * The element does not contain, as a descendant, another *operable*
21
+ * interactive control (e.g. a <button> wrapping a <select>, or a link
22
+ * containing a checkbox). Nested interactive controls are not reliably
23
+ * announced or operable via assistive technology — activating the outer
24
+ * control and the inner one become ambiguous, and some AT only exposes
25
+ * one of the two.
24
26
  * @implementation-notes
25
- * - Reports on the outer (containing) control, not the nested descendant —
26
- * this engine considers the container the fixable unit ("move the nested
27
- * control outside this element").
28
- * - A container can be reported once even with multiple nested
29
- * descendants (listed together); a deeply nested chain (A > B > C, all
30
- * interactive) reports both A and B as separate occurrences, since each
31
- * genuinely contains a nested interactive control.
27
+ * - A descendant counts as a nested interactive control only when it is both
28
+ * (a) a native interactive element or an explicit ARIA widget role and
29
+ * (b) operable: exposed to the accessibility tree and platform-focusable
30
+ * (natively focusable, or focusable via tabindex), per
31
+ * helpers.getFocusableInfo, which accounts for contenteditable, :disabled,
32
+ * inert, and invalid/negative tabindex.
33
+ * - A widget-role child that its container drives rather than exposes as its
34
+ * own focus target creates no operability ambiguity and does not count:
35
+ * a role="option" inside a listbox/combobox, a role="tab" inside a tablist,
36
+ * a role="treeitem" inside a tree, a role="menuitem" inside a menu, or a
37
+ * role="radio" inside a radiogroup. Composites manage such children with one
38
+ * of two focus models, and both are exempt: aria-activedescendant (the child
39
+ * has no tabindex and is not focusable) and roving tabindex (the active
40
+ * child carries tabindex="0" and the rest tabindex="-1"). Under roving
41
+ * tabindex the owned child IS platform-focusable, so focusability alone
42
+ * cannot be the discriminator; membership in the container's owned-child set
43
+ * is what exempts it. A control that is itself focusable while nested in a
44
+ * control it does NOT belong to still counts: a <button> inside an <a href>,
45
+ * a focusable role="button" inside a link, an editable field inside a
46
+ * control, or an orphan role="option" with no owning listbox/combobox.
47
+ * - A disabled native control (<button disabled>, <input disabled>) and an
48
+ * inert descendant are not focusable, so they do not nest an interactive
49
+ * control; a display:none or aria-hidden descendant is not exposed to AT
50
+ * and is likewise out of scope. aria-disabled leaves an element focusable,
51
+ * so it still counts.
52
+ * - Occurrences report the outer (containing) control, the fixable unit
53
+ * ("move the nested control outside this element"), not the descendant.
54
+ * - Only the shallowest operable descendants are attributed to a container.
55
+ * In a chain A > B > C where all three are operable, A is reported for B
56
+ * and B for C; A is not reported for C, whose nesting belongs to its
57
+ * nearest operable ancestor B.
32
58
  */
33
59
 
34
60
  const id = 'nested-interactive-controls-absent';
@@ -92,6 +118,8 @@ function runInPage(ctx) {
92
118
 
93
119
  const isAccTreeEligible =
94
120
  helpers && typeof helpers.isAccTreeEligible === 'function' ? helpers.isAccTreeEligible : null;
121
+ const getFocusableInfo =
122
+ helpers && typeof helpers.getFocusableInfo === 'function' ? helpers.getFocusableInfo : null;
95
123
 
96
124
  function isEligible(node) {
97
125
  if (!isAccTreeEligible) return true;
@@ -103,6 +131,122 @@ function runInPage(ctx) {
103
131
  }
104
132
  }
105
133
 
134
+ function matchesInteractive(node) {
135
+ return !!(
136
+ node &&
137
+ node.nodeType === 1 &&
138
+ typeof node.matches === 'function' &&
139
+ node.matches(INTERACTIVE_SELECTOR)
140
+ );
141
+ }
142
+
143
+ // A composite widget owns children of a fixed role and drives their focus
144
+ // itself (via roving tabindex or aria-activedescendant). The roving-tabindex
145
+ // model gives the active child tabindex="0" and the rest tabindex="-1", so
146
+ // the owned children ARE platform-focusable even though the container, not
147
+ // the child, is the operable unit. Such a child is part of the composite,
148
+ // not a control nested inside another control, so it must not be reported
149
+ // regardless of its tabindex. The map is keyed by the child role and lists
150
+ // the container roles that legitimately own it.
151
+ const COMPOSITE_CHILD_CONTAINERS = {
152
+ option: ['listbox', 'combobox'],
153
+ tab: ['tablist'],
154
+ treeitem: ['tree'],
155
+ menuitem: ['menu', 'menubar'],
156
+ menuitemcheckbox: ['menu', 'menubar'],
157
+ menuitemradio: ['menu', 'menubar'],
158
+ radio: ['radiogroup']
159
+ };
160
+
161
+ function getExplicitRole(node) {
162
+ if (!node || node.nodeType !== 1 || typeof node.getAttribute !== 'function') return '';
163
+ const raw = node.getAttribute('role');
164
+ if (!raw) return '';
165
+ // role accepts a space-separated fallback list; the first token wins.
166
+ const first = raw.trim().split(/\s+/)[0];
167
+ return first ? first.toLowerCase() : '';
168
+ }
169
+
170
+ function parentElementOf(node) {
171
+ if (!node) return null;
172
+ if (node.parentElement) return node.parentElement;
173
+ const p = node.parentNode;
174
+ return p && p.nodeType === 1 ? p : null;
175
+ }
176
+
177
+ // True when `node` is an owned child of a composite widget: its role is a
178
+ // composite-child role and a matching container role is present on one of
179
+ // its ancestors. The roving tab stop (tabindex="0") such a container places
180
+ // on its active child does not make that child an independently nested
181
+ // control.
182
+ function isManagedCompositeChild(node) {
183
+ const role = getExplicitRole(node);
184
+ const containers = COMPOSITE_CHILD_CONTAINERS[role];
185
+ if (!containers) return false;
186
+ let p = parentElementOf(node);
187
+ while (p && p.nodeType === 1) {
188
+ if (containers.indexOf(getExplicitRole(p)) !== -1) return true;
189
+ p = parentElementOf(p);
190
+ }
191
+ return false;
192
+ }
193
+
194
+ // Operable = a native-interactive / ARIA-widget element that is exposed to
195
+ // the accessibility tree and platform-focusable. A widget-role element with
196
+ // no independent focus (e.g. a role="option" with no tabindex, driven by
197
+ // its container via roving tabindex or aria-activedescendant) is not
198
+ // operable and does not nest an interactive control. When no focus model is
199
+ // available, role membership alone qualifies. (Composite-owned children are
200
+ // handled earlier as attribution boundaries in collectNestedOperable, so
201
+ // they never reach here.)
202
+ function isOperableInteractive(node) {
203
+ if (!matchesInteractive(node)) return false;
204
+ if (!isEligible(node)) return false;
205
+ if (!getFocusableInfo) return true;
206
+ try {
207
+ const info = getFocusableInfo(node, ctx);
208
+ return !!(info && info.focusable);
209
+ } catch {
210
+ return true;
211
+ }
212
+ }
213
+
214
+ // Shallowest operable interactive descendants of `root`. Traversal stops at
215
+ // each counted node instead of descending into it, so a control nested
216
+ // inside another operable control is attributed to its nearest operable
217
+ // ancestor rather than to every enclosing container. Eligibility is applied
218
+ // per node during the walk, so hidden or aria-hidden subtrees drop out.
219
+ function collectNestedOperable(root) {
220
+ const out = [];
221
+ const top = root && root.children;
222
+ if (!top || !top.length) return out;
223
+ const stack = [];
224
+ for (let i = top.length - 1; i >= 0; i--) stack.push(top[i]);
225
+ while (stack.length) {
226
+ const node = stack.pop();
227
+ if (node && node.nodeType === 1) {
228
+ // A composite-owned child (option in a listbox/combobox, tab in a
229
+ // tablist, ...) is not a nested interactive control: its container
230
+ // owns it and drives its focus (roving tabindex or
231
+ // aria-activedescendant). Treat it as an attribution boundary — do not
232
+ // count it, and do not descend past it. Any control genuinely nested
233
+ // inside it is attributed to the child itself (examined as its own
234
+ // container in the main loop), keeping the report at the nearest
235
+ // interactive ancestor rather than bubbling up to the composite.
236
+ if (isManagedCompositeChild(node)) continue;
237
+ if (isOperableInteractive(node)) {
238
+ out.push(node);
239
+ continue; // do not descend into a counted control
240
+ }
241
+ }
242
+ const kids = node && node.children;
243
+ if (kids && kids.length) {
244
+ for (let i = kids.length - 1; i >= 0; i--) stack.push(kids[i]);
245
+ }
246
+ }
247
+ return out;
248
+ }
249
+
106
250
  const nodes = helpers.queryAllSmart
107
251
  ? helpers.queryAllSmart(INTERACTIVE_SELECTOR)
108
252
  : helpers.queryAll(INTERACTIVE_SELECTOR);
@@ -111,53 +255,37 @@ function runInPage(ctx) {
111
255
  let applicableCount = 0;
112
256
 
113
257
  for (const el of nodes) {
114
- if (!el || !el.querySelectorAll) continue;
258
+ if (!el || el.nodeType !== 1) continue;
115
259
  if (!isEligible(el)) continue;
116
260
 
117
261
  applicableCount += 1;
118
262
 
119
- // The nested search uses the raw native querySelectorAll (not
120
- // helpers.queryAllSmart), so it isn't subject to that helper's
121
- // default hidden-content policy at all -- not even hard CSS-based
122
- // hiding, let alone aria-hidden. A nested descendant that is never
123
- // actually rendered or exposed to AT (display:none, aria-hidden,
124
- // etc.) creates no real ambiguity for ANY user, since it isn't there
125
- // to be confused with the outer control.
126
- let nested;
127
- try {
128
- nested = Array.from(el.querySelectorAll(INTERACTIVE_SELECTOR)).filter(isEligible);
129
- } catch {
130
- nested = [];
131
- }
263
+ const nested = collectNestedOperable(el);
132
264
  if (!nested.length) continue;
133
265
 
134
266
  const nestedTags = nested.map((n) => (n && n.tagName ? n.tagName.toLowerCase() : 'unknown'));
135
- const dedupedNestedTags = [
136
- ...new Set(nested.map((n) => (n && n.tagName ? n.tagName.toLowerCase() : 'unknown')))
137
- ];
267
+ const dedupedNestedTags = [...new Set(nestedTags)];
138
268
 
139
269
  const tag = el.tagName.toLowerCase();
140
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
141
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
142
-
143
- occurrences.push({
144
- selector: stableSelector,
145
- html,
146
- summary: 'This interactive control contains one or more other interactive controls.',
147
- hint: 'Move the nested interactive control(s) outside this element; nested interactive controls are not reliably operable via assistive technology.',
148
- i18n: {
149
- summaryKey: 'nestedInteractiveControlsAbsent_summary_fail',
150
- hintKey: 'nestedInteractiveControlsAbsent_hint_fail',
151
- params: { element: tag, nestedElements: dedupedNestedTags.join(', ') }
152
- },
153
- data: {
154
- details: {
155
- reasonCode: 'NESTED_INTERACTIVE_CONTROL',
156
- element: tag,
157
- nestedElements: nestedTags
270
+
271
+ occurrences.push(
272
+ helpers.reportOccurrence(el, {
273
+ summary: 'This interactive control contains one or more other interactive controls.',
274
+ hint: 'Move the nested interactive control(s) outside this element; nested interactive controls are not reliably operable via assistive technology.',
275
+ i18n: {
276
+ summaryKey: 'nestedInteractiveControlsAbsent_summary_fail',
277
+ hintKey: 'nestedInteractiveControlsAbsent_hint_fail',
278
+ params: { element: tag, nestedElements: dedupedNestedTags.join(', ') }
279
+ },
280
+ data: {
281
+ details: {
282
+ reasonCode: 'NESTED_INTERACTIVE_CONTROL',
283
+ element: tag,
284
+ nestedElements: nestedTags
285
+ }
158
286
  }
159
- }
160
- });
287
+ })
288
+ );
161
289
  }
162
290
 
163
291
  if (applicableCount === 0) {
@@ -9,9 +9,8 @@
9
9
  * @standard WCAG 2.2
10
10
  * @sc 1.1.1
11
11
  * @applicability
12
- * Applies to <object> elements that are exposed to assistive technologies.
13
- * Objects otherwise hidden from the accessibility tree remain applicable
14
- * if they are tabbable or referenced by IDREF relationships (per engine eligibility checks).
12
+ * Applies to <object> elements included in the accessibility tree.
13
+ * Hidden objects are excluded whether or not they are focusable.
15
14
  * role="presentation"/role="none" are excluded only when not focusable.
16
15
  * @expectation
17
16
  * Each applicable <object> provides a text alternative via:
@@ -71,8 +70,15 @@ function runInPage(ctx) {
71
70
  const getEligibilityInfo =
72
71
  helpers && typeof helpers.getEligibilityInfo === 'function' ? helpers.getEligibilityInfo : null;
73
72
 
74
- const isAccTreeEligible =
75
- helpers && typeof helpers.isAccTreeEligible === 'function' ? helpers.isAccTreeEligible : null;
73
+ // ACT 8fc3b6 applies only to objects included in the accessibility tree, so a
74
+ // focusable object inside aria-hidden is out of scope; aria-hidden-focus
75
+ // reports that markup instead.
76
+ const isEligibleHelper =
77
+ helpers && typeof helpers.isIncludedInAccessibilityTree === 'function'
78
+ ? helpers.isIncludedInAccessibilityTree
79
+ : helpers && typeof helpers.isAccTreeEligible === 'function'
80
+ ? helpers.isAccTreeEligible
81
+ : null;
76
82
 
77
83
  const getFocusableInfo =
78
84
  helpers && typeof helpers.getFocusableInfo === 'function' ? helpers.getFocusableInfo : null;
@@ -148,14 +154,15 @@ function runInPage(ctx) {
148
154
  for (const el of objects) {
149
155
  if (!el || !el.getAttribute) continue;
150
156
 
151
- if (isAccTreeEligible) {
157
+ if (isEligibleHelper) {
152
158
  const elig = (() => {
153
159
  try {
154
- return isAccTreeEligible(el, ctx);
160
+ return isEligibleHelper(el, ctx);
155
161
  } catch {
156
162
  return { eligible: true, reasons: [] };
157
163
  }
158
164
  })();
165
+ if (elig === false) continue;
159
166
  if (elig && elig.eligible === false) continue;
160
167
  }
161
168
 
@@ -83,9 +83,16 @@ function runInPage(ctx) {
83
83
  return '';
84
84
  }
85
85
 
86
+ // Naming rules apply only to elements included in the accessibility tree
87
+ // (ACT c487ae and siblings), which excludes focusable aria-hidden content.
88
+ // aria-hidden-focus (ACT 6cfa84) covers that markup instead.
86
89
  function isEligibleAcc(helpers, el, ctx) {
87
90
  const fn =
88
- helpers && typeof helpers.isAccTreeEligible === 'function' ? helpers.isAccTreeEligible : null;
91
+ helpers && typeof helpers.isIncludedInAccessibilityTree === 'function'
92
+ ? helpers.isIncludedInAccessibilityTree
93
+ : helpers && typeof helpers.isAccTreeEligible === 'function'
94
+ ? helpers.isAccTreeEligible
95
+ : null;
89
96
  if (!fn) return true;
90
97
  try {
91
98
  const r = fn(el, ctx);
@@ -138,24 +145,22 @@ function runInPage(ctx) {
138
145
  }
139
146
  })()
140
147
  : null;
141
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
142
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
143
-
144
- occurrences.push({
145
- selector: stableSelector,
146
- html,
147
- summary: 'This element has no accessible name.',
148
- hint: 'Provide aria-label or aria-labelledby (preferred), or provide visible text that is not hidden from assistive technologies.',
149
- i18n: {
150
- summaryKey: 'optionNamePresent_summary_fail',
151
- hintKey: 'optionNamePresent_hint_fail',
152
- params: { controlType: 'option' }
153
- },
154
- data: {
155
- details: { reasonCode: 'name_missing', controlType: 'option', methodTried: res.method },
156
- visibilityFilter: eligInfo || { targetSet: 'acc', accEligible: null, reasons: [] }
157
- }
158
- });
148
+
149
+ occurrences.push(
150
+ helpers.reportOccurrence(el, {
151
+ summary: 'This element has no accessible name.',
152
+ hint: 'Provide aria-label or aria-labelledby (preferred), or provide visible text that is not hidden from assistive technologies.',
153
+ i18n: {
154
+ summaryKey: 'optionNamePresent_summary_fail',
155
+ hintKey: 'optionNamePresent_hint_fail',
156
+ params: { controlType: 'option' }
157
+ },
158
+ data: {
159
+ details: { reasonCode: 'name_missing', controlType: 'option', methodTried: res.method },
160
+ visibilityFilter: eligInfo || { targetSet: 'acc', accEligible: null, reasons: [] }
161
+ }
162
+ })
163
+ );
159
164
  }
160
165
 
161
166
  if (applicableCount === 0) {
@@ -67,9 +67,16 @@ function runInPage(ctx) {
67
67
  return '';
68
68
  }
69
69
 
70
+ // Naming rules apply only to elements included in the accessibility tree
71
+ // (ACT c487ae and siblings), which excludes focusable aria-hidden content.
72
+ // aria-hidden-focus (ACT 6cfa84) covers that markup instead.
70
73
  function isEligibleAcc(helpers, el, ctx) {
71
74
  const fn =
72
- helpers && typeof helpers.isAccTreeEligible === 'function' ? helpers.isAccTreeEligible : null;
75
+ helpers && typeof helpers.isIncludedInAccessibilityTree === 'function'
76
+ ? helpers.isIncludedInAccessibilityTree
77
+ : helpers && typeof helpers.isAccTreeEligible === 'function'
78
+ ? helpers.isAccTreeEligible
79
+ : null;
73
80
  if (!fn) return true;
74
81
  try {
75
82
  const r = fn(el, ctx);
@@ -128,28 +135,26 @@ function runInPage(ctx) {
128
135
  }
129
136
  })()
130
137
  : null;
131
- const stableSelector = helpers.buildSelector ? helpers.buildSelector(el) : 'html';
132
- const html = helpers.getOuterHtmlSnippet ? helpers.getOuterHtmlSnippet(el) : el.outerHTML || '';
133
-
134
- occurrences.push({
135
- selector: stableSelector,
136
- html,
137
- summary: 'This progress bar has no accessible name.',
138
- hint: "Provide aria-label, aria-labelledby, or a title attribute — visible text content is not exposed as this progress bar's accessible name.",
139
- i18n: {
140
- summaryKey: 'progressbarNamePresent_summary_fail',
141
- hintKey: 'progressbarNamePresent_hint_fail',
142
- params: {}
143
- },
144
- data: {
145
- details: {
146
- reasonCode: 'name_missing',
147
- controlType: 'progressbar',
148
- methodTried: res.method
138
+
139
+ occurrences.push(
140
+ helpers.reportOccurrence(el, {
141
+ summary: 'This progress bar has no accessible name.',
142
+ hint: "Provide aria-label, aria-labelledby, or a title attribute — visible text content is not exposed as this progress bar's accessible name.",
143
+ i18n: {
144
+ summaryKey: 'progressbarNamePresent_summary_fail',
145
+ hintKey: 'progressbarNamePresent_hint_fail',
146
+ params: {}
149
147
  },
150
- visibilityFilter: eligInfo || { targetSet: 'acc', accEligible: null, reasons: [] }
151
- }
152
- });
148
+ data: {
149
+ details: {
150
+ reasonCode: 'name_missing',
151
+ controlType: 'progressbar',
152
+ methodTried: res.method
153
+ },
154
+ visibilityFilter: eligInfo || { targetSet: 'acc', accEligible: null, reasons: [] }
155
+ }
156
+ })
157
+ );
153
158
  }
154
159
 
155
160
  if (applicableCount === 0) {