Skip to content

Commit fd94818

Browse files
Avoid isIdentifier() crash on null/undefined values (#778)
* Avoid isIdentifier() crash on null/undefined values * Create gold-candles-sing.md Co-authored-by: Jovi De Croock <[email protected]>
1 parent a1d5f7e commit fd94818

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/gold-candles-sing.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wmr": patch
3+
---
4+
5+
Avoid isIdentifier() crash on null/undefined values

packages/wmr/src/lib/acorn-traverse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ const TYPES = {
862862
/** @type {(a:Node,b?:Node)=>boolean} */
863863
isIdentifier(a, b) {
864864
if (a instanceof Path) a = a.node;
865-
if (a.type !== 'Identifier') return false;
865+
if (!a || a.type !== 'Identifier') return false;
866866
return !b || TYPES.isNodesEquivalent(a, b);
867867
},
868868
react: {

0 commit comments

Comments
 (0)