@babel/plugin-transform-react-jsx
Advanced tools
Comparing version 7.16.7 to 7.17.3
@@ -71,3 +71,3 @@ "use strict"; | ||
if (isThisAllowed(path)) { | ||
if (isThisAllowed(path.scope)) { | ||
attributes.push(_core.types.jsxAttribute(_core.types.jsxIdentifier("__self"), _core.types.jsxExpressionContainer(_core.types.thisExpression()))); | ||
@@ -212,14 +212,2 @@ } | ||
function getThisFunctionParent(path) { | ||
let scope = path.scope; | ||
do { | ||
if (scope.path.isFunctionParent() && !scope.path.isArrowFunctionExpression()) { | ||
return scope.path; | ||
} | ||
} while (scope = scope.parent); | ||
return null; | ||
} | ||
function isDerivedClass(classPath) { | ||
@@ -229,18 +217,26 @@ return classPath.node.superClass !== null; | ||
function isThisAllowed(path) { | ||
const parentMethodOrFunction = getThisFunctionParent(path); | ||
function isThisAllowed(scope) { | ||
do { | ||
const { | ||
path | ||
} = scope; | ||
if (parentMethodOrFunction === null) { | ||
return true; | ||
} | ||
if (path.isFunctionParent() && !path.isArrowFunctionExpression()) { | ||
if (!path.isMethod()) { | ||
return true; | ||
} | ||
if (!parentMethodOrFunction.isMethod()) { | ||
return true; | ||
} | ||
if (path.node.kind !== "constructor") { | ||
return true; | ||
} | ||
if (parentMethodOrFunction.node.kind !== "constructor") { | ||
return true; | ||
} | ||
return !isDerivedClass(path.parentPath.parentPath); | ||
} | ||
return !isDerivedClass(parentMethodOrFunction.parentPath.parentPath); | ||
if (path.isTSModuleBlock()) { | ||
return false; | ||
} | ||
} while (scope = scope.parent); | ||
return true; | ||
} | ||
@@ -247,0 +243,0 @@ |
{ | ||
"name": "@babel/plugin-transform-react-jsx", | ||
"version": "7.16.7", | ||
"version": "7.17.3", | ||
"description": "Turn JSX into React function calls", | ||
@@ -24,3 +24,3 @@ "repository": { | ||
"@babel/plugin-syntax-jsx": "^7.16.7", | ||
"@babel/types": "^7.16.7" | ||
"@babel/types": "^7.17.0" | ||
}, | ||
@@ -31,5 +31,5 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@babel/core": "^7.16.7", | ||
"@babel/core": "^7.17.3", | ||
"@babel/helper-plugin-test-runner": "^7.16.7", | ||
"@babel/traverse": "^7.16.7" | ||
"@babel/traverse": "^7.17.3" | ||
}, | ||
@@ -36,0 +36,0 @@ "engines": { |
24137
503
Updated@babel/types@^7.17.0