Skip to content

Commit f991346

Browse files
committed
Only allow JSXAttribute types in the attribute check in isInteractiveElement and isInteractiveRole utils
1 parent 8145d31 commit f991346

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/util/isInteractiveElement.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ const pureInteractiveRoleElements = [...elementRoles.entries()]
4343
elementAttributes.length === 0 ||
4444
elementAttributes.every(
4545
(controlAttr): boolean => attributes.some(
46-
(attr): boolean => (
47-
controlAttr.name === propName(attr).toLowerCase()
48-
&& controlAttr.value === getLiteralPropValue(attr)
49-
),
46+
(attr): boolean => {
47+
if (attr.type !== 'JSXAttribute') {
48+
return false;
49+
}
50+
return controlAttr.name === propName(attr).toLowerCase()
51+
&& controlAttr.value === getLiteralPropValue(attr);
52+
},
5053
),
5154
);
5255
// [].some is used here because some elements are associated with both

src/util/isNonInteractiveElement.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ const pureNonInteractiveElements = [...elementRoles.entries()]
4444
elementAttributes.length === 0 ||
4545
elementAttributes.every(
4646
(controlAttr): boolean => attributes.some(
47-
(attr): boolean => (
48-
controlAttr.name === propName(attr).toLowerCase()
49-
&& controlAttr.value === getLiteralPropValue(attr)
50-
),
47+
(attr): boolean => {
48+
if (attr.type !== 'JSXAttribute') {
49+
return false;
50+
}
51+
return controlAttr.name === propName(attr).toLowerCase()
52+
&& controlAttr.value === getLiteralPropValue(attr);
53+
},
5154
),
5255
);
5356
return passedAttrCheck && [...roleSet.keys()].every(

0 commit comments

Comments
 (0)