diff --git a/src/_utils.js b/src/_utils.js index 7b6a02ac..c89025f4 100644 --- a/src/_utils.js +++ b/src/_utils.js @@ -129,11 +129,13 @@ export const validateExpressionVisitor = { } }, Identifier(path, scope) { - if (t.isMemberExpression(path.parentPath)) { + const { name } = path.node + + if (t.isMemberExpression(path.parentPath) && scope.hasOwnBinding(name)) { return } - const { name } = path.node - if (scope.hasOwnBinding(name)) { + + if (scope.hasOwnBinding(name) || path.scope.hasOwnBinding(name)) { throw path.buildCodeFrameError( `Expected \`${name}\` ` + `to not come from the closest scope.\n` + diff --git a/test/__snapshots__/attribute.js.snap b/test/__snapshots__/attribute.js.snap index 66050b83..65aba8f2 100644 --- a/test/__snapshots__/attribute.js.snap +++ b/test/__snapshots__/attribute.js.snap @@ -53,6 +53,36 @@ export const Test6 = ({ color }) =>
dynamic only
<_JSXStyle styleId={\\"1947484460\\"} css={\`p.__jsx-style-dynamic-selector{color:\${color};}\`} dynamic={[color]} /> +dynamic with scoped compound variable
+ <_JSXStyle styleId={\\"1791723528\\"} css={\`p.__jsx-style-dynamic-selector{color:\${innerProps.color};}\`} dynamic={[innerProps.color]} /> +dynamic with compound variable
+ <_JSXStyle styleId={\\"248922593\\"} css={\`p.__jsx-style-dynamic-selector{color:\${innerProps.color};}\`} dynamic={[innerProps.color]} /> +dynamic with constant variable
+ <_JSXStyle styleId={\\"461505126\\"} css={\`p.jsx-461505126{color:\${foo};}\`} />external only
- - + +external and static
- +external and dynamic
- +external, static and dynamic
- +static only
static and dynamic
dynamic only
dynamic with scoped compound variable
+ +dynamic with compound variable
+ +dynamic with constant variable
+ +