File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,7 @@ function trimLikeReact(text) {
60
60
function isKeyedElement ( node ) {
61
61
return node . type === 'JSXElement' &&
62
62
node . openingElement . attributes &&
63
- node . openingElement . attributes . some ( attribute => (
64
- attribute . type === 'JSXAttribute' &&
65
- attribute . name &&
66
- attribute . name . type === 'JSXIdentifier' &&
67
- attribute . name . name === 'key'
68
- ) ) ;
63
+ node . openingElement . attributes . some ( jsxUtil . isJSXAttributeKey ) ;
69
64
}
70
65
71
66
module . exports = {
Original file line number Diff line number Diff line change @@ -64,8 +64,20 @@ function isJSX(node) {
64
64
return node && [ 'JSXElement' , 'JSXFragment' ] . indexOf ( node . type ) >= 0 ;
65
65
}
66
66
67
+ /**
68
+ * Check if node is like `key={...}` as in `<Foo key={...} />`
69
+ * @param {ASTNode } node
70
+ */
71
+ function isJSXAttributeKey ( node ) {
72
+ return node . type === 'JSXAttribute' &&
73
+ node . name &&
74
+ node . name . type === 'JSXIdentifier' &&
75
+ node . name . name === 'key' ;
76
+ }
77
+
67
78
module . exports = {
68
79
isDOMComponent,
69
80
isFragment,
70
- isJSX
81
+ isJSX,
82
+ isJSXAttributeKey
71
83
} ;
You can’t perform that action at this time.
0 commit comments