Skip to content

Commit 054c3a0

Browse files
committed
fix: normalize role/aria-hidden values — trim + lowercase (Copilot review)
1 parent 0e99723 commit 054c3a0

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ function getTextAttr(node, name) {
3232
const MENUITEM_ROLES = new Set(['menuitem', 'menuitemcheckbox', 'menuitemradio']);
3333

3434
function getRole(node) {
35-
return getTextAttr(node, 'role');
35+
// ARIA role values are case-insensitive per HTML spec. Match the
36+
// normalization used elsewhere (template-no-invalid-role, etc.) and split
37+
// on whitespace to honor role-fallback — we use the first token here,
38+
// which matches how aria-query and elementRoles resolve roles.
39+
const raw = getTextAttr(node, 'role');
40+
if (!raw) {
41+
return raw;
42+
}
43+
return raw.trim().toLowerCase().split(/\s+/u)[0];
3644
}
3745

3846
function isCompositeWidgetPattern(parentRole, childRole) {

0 commit comments

Comments
 (0)