Skip to content

Commit dff1d91

Browse files
committed
fix(#27): address round-2 Copilot review (normalize role via getRole; pin gridcell/row/columnheader/rowheader)
1 parent 054c3a0 commit dff1d91

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

lib/rules/template-no-nested-interactive.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ module.exports = {
146146
return true;
147147
}
148148

149-
// Check role
150-
const role = getTextAttr(node, 'role');
149+
// Check role — normalize via getRole so that `role="BUTTON"` and
150+
// `role="button checkbox"` match INTERACTIVE_ROLES. This mirrors the
151+
// resolution used by isCompositeWidgetPattern below.
152+
const role = getRole(node);
151153
if (role && INTERACTIVE_ROLES.has(role)) {
152154
return true;
153155
}
@@ -190,7 +192,7 @@ module.exports = {
190192
if (tag === 'a' && hasAttr(node, 'href')) {
191193
return false;
192194
}
193-
const role = getTextAttr(node, 'role');
195+
const role = getRole(node);
194196
if (role && INTERACTIVE_ROLES.has(role)) {
195197
return false;
196198
}

tests/lib/utils/interactive-roles-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ describe('INTERACTIVE_ROLES', () => {
4040
}
4141
});
4242

43+
describe('composite widget children (widget-descended per aria-query)', () => {
44+
// Pin behaviorally-important widget-descended roles both of the rules
45+
// previously relied on. Explicit assertions here make taxonomy drift
46+
// easier to diagnose than the size-only drift check below.
47+
for (const role of ['gridcell', 'row', 'columnheader', 'rowheader']) {
48+
it(`includes "${role}"`, () => {
49+
expect(INTERACTIVE_ROLES.has(role)).toBe(true);
50+
});
51+
}
52+
});
53+
4354
describe('manual override', () => {
4455
it('includes "toolbar" (not widget-descended per aria-query; added per APG convention)', () => {
4556
expect(INTERACTIVE_ROLES.has('toolbar')).toBe(true);

0 commit comments

Comments
 (0)