Skip to content

Commit 9c49f26

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

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
@@ -150,8 +150,10 @@ module.exports = {
150150
return true;
151151
}
152152

153-
// Check role
154-
const role = getTextAttr(node, 'role');
153+
// Check role — normalize via getRole so that `role="BUTTON"` and
154+
// `role="button checkbox"` match INTERACTIVE_ROLES. This mirrors the
155+
// resolution used by isCompositeWidgetPattern below.
156+
const role = getRole(node);
155157
if (role && INTERACTIVE_ROLES.has(role)) {
156158
return true;
157159
}
@@ -194,7 +196,7 @@ module.exports = {
194196
if (tag === 'a' && hasAttr(node, 'href')) {
195197
return false;
196198
}
197-
const role = getTextAttr(node, 'role');
199+
const role = getRole(node);
198200
if (role && INTERACTIVE_ROLES.has(role)) {
199201
return false;
200202
}

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)