Skip to content

Commit 9211525

Browse files
committed
refactor(template-no-noninteractive-tabindex): consume shared INTERACTIVE_ROLES util (Copilot review)
Replace inline derivation (widget/command/composite/input/range ancestor union) with the shared util's (widget-ancestor only + toolbar). The util is more spec-correct: 'meter' was in the inline set via its 'range' ancestor but per ARIA 1.2 it's a structure/section role, not a widget. All 49 existing tests pass. Addresses the dead-import concern AND the 'two sources of truth' concern in one change.
1 parent e46bb77 commit 9211525

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

lib/rules/template-no-noninteractive-tabindex.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,7 @@
11
const { dom, roles } = require('aria-query');
22
const { isNativeElement } = require('../utils/is-native-element');
33
const { isHtmlInteractiveContent } = require('../utils/html-interactive-content');
4-
5-
// Interactive ARIA roles (widget/command/composite/input/range subtypes) —
6-
// tabindex is required for widget keyboard access, so allow it when present.
7-
const INTERACTIVE_ROLES = buildInteractiveRoleSet();
8-
9-
function buildInteractiveRoleSet() {
10-
const result = new Set();
11-
for (const [role, def] of roles) {
12-
if (def.abstract) {
13-
continue;
14-
}
15-
const ancestors = new Set();
16-
for (const chain of def.superClass || []) {
17-
for (const cls of chain) {
18-
ancestors.add(cls);
19-
}
20-
}
21-
if (
22-
ancestors.has('widget') ||
23-
ancestors.has('command') ||
24-
ancestors.has('composite') ||
25-
ancestors.has('input') ||
26-
ancestors.has('range')
27-
) {
28-
result.add(role);
29-
}
30-
}
31-
// toolbar is practically widget-like — see jsx-a11y's note.
32-
result.add('toolbar');
33-
return result;
34-
}
4+
const { INTERACTIVE_ROLES } = require('../utils/interactive-roles');
355

366
function findAttr(node, name) {
377
// HTML attribute names are case-insensitive. Normalize both sides so

0 commit comments

Comments
 (0)