Skip to content

Commit 4a79503

Browse files
committed
Guard against non-JSXAttribute nodes in isInteractiveElement and isNoninteractiveElement
1 parent a94ff98 commit 4a79503

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/util/isInteractiveElement.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ function attributesComparator(baseAttributes = [], attributes = []): boolean {
9797
return baseAttributes.every(
9898
(baseAttr): boolean => attributes.some(
9999
(attribute): boolean => {
100+
// Guard against non-JSXAttribute nodes like JSXSpreadAttribute
101+
if (attribute.type !== 'JSXAttribute') {
102+
return false;
103+
}
100104
let attrMatches = false;
101105
let valueMatches = true;
102106
// Attribute matches.
@@ -107,7 +111,6 @@ function attributesComparator(baseAttributes = [], attributes = []): boolean {
107111
if (baseAttr.value) {
108112
valueMatches = baseAttr.value === getLiteralPropValue(attribute);
109113
}
110-
// attribute.type === 'JSXAttribute'
111114
return attrMatches && valueMatches;
112115
},
113116
),

src/util/isNonInteractiveElement.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ function attributesComparator(baseAttributes = [], attributes = []): boolean {
9292
return baseAttributes.every(
9393
(baseAttr): boolean => attributes.some(
9494
(attribute): boolean => {
95+
// Guard against non-JSXAttribute nodes like JSXSpreadAttribute
96+
if (attribute.type !== 'JSXAttribute') {
97+
return false;
98+
}
9599
let attrMatches = false;
96100
let valueMatches = true;
97101
// Attribute matches.
@@ -102,7 +106,6 @@ function attributesComparator(baseAttributes = [], attributes = []): boolean {
102106
if (baseAttr.value) {
103107
valueMatches = baseAttr.value === getLiteralPropValue(attribute);
104108
}
105-
// attribute.type === 'JSXAttribute'
106109
return attrMatches && valueMatches;
107110
},
108111
),

0 commit comments

Comments
 (0)