|
1 | | -import * as t from '@babel/types'; |
2 | 1 | import type * as babel from '@babel/core'; |
3 | | -import { getDescriptiveName } from './get-descriptive-name'; |
4 | | -import { isPathValid, unwrapNode } from './unwrap'; |
| 2 | +import * as t from '@babel/types'; |
| 3 | +import { isComponentishName } from './checks'; |
5 | 4 | import { generateUniqueName } from './generate-unique-name'; |
| 5 | +import { getDescriptiveName } from './get-descriptive-name'; |
6 | 6 | import { getRootStatementPath } from './get-root-statement-path'; |
7 | | -import { isComponentishName } from './checks'; |
| 7 | +import { isStatementTopLevel } from './is-statement-top-level'; |
| 8 | +import { isPathValid, unwrapNode } from './unwrap'; |
8 | 9 |
|
9 | 10 | const REFRESH_JSX_SKIP = /^\s*@refresh jsx-skip\s*$/; |
10 | 11 |
|
@@ -188,6 +189,15 @@ function extractJSXExpressionsFromJSXElement( |
188 | 189 | /^[A-Z_]/.test(openingName.node.name)) || |
189 | 190 | isPathValid(openingName, t.isJSXMemberExpression) |
190 | 191 | ) { |
| 192 | + if (isPathValid(openingName, t.isJSXIdentifier)) { |
| 193 | + const binding = path.scope.getBinding(openingName.node.name); |
| 194 | + if (binding) { |
| 195 | + const statementPath = binding.path.getStatementParent(); |
| 196 | + if (statementPath && isStatementTopLevel(statementPath)) { |
| 197 | + return; |
| 198 | + } |
| 199 | + } |
| 200 | + } |
191 | 201 | const key = pushAttribute( |
192 | 202 | state, |
193 | 203 | convertJSXOpeningToExpression(openingName.node), |
|
0 commit comments