@babel/plugin-transform-react-jsx-self
Advanced tools
Comparing version 7.14.5 to 7.14.9
@@ -14,8 +14,46 @@ "use strict"; | ||
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) { | ||
return classPath.node.superClass !== null; | ||
} | ||
function isThisAllowed(path) { | ||
const parentMethodOrFunction = getThisFunctionParent(path); | ||
if (parentMethodOrFunction === null) { | ||
return true; | ||
} | ||
if (!parentMethodOrFunction.isMethod()) { | ||
return true; | ||
} | ||
if (parentMethodOrFunction.node.kind !== "constructor") { | ||
return true; | ||
} | ||
return !isDerivedClass(parentMethodOrFunction.parentPath.parentPath); | ||
} | ||
var _default = (0, _helperPluginUtils.declare)(api => { | ||
api.assertVersion(7); | ||
const visitor = { | ||
JSXOpeningElement({ | ||
node | ||
}) { | ||
JSXOpeningElement(path) { | ||
if (!isThisAllowed(path)) { | ||
return; | ||
} | ||
const node = path.node; | ||
const id = _core.types.jsxIdentifier(TRACE_ID); | ||
@@ -22,0 +60,0 @@ |
{ | ||
"name": "@babel/plugin-transform-react-jsx-self", | ||
"version": "7.14.5", | ||
"version": "7.14.9", | ||
"description": "Add a __self prop to all JSX Elements", | ||
@@ -26,3 +26,3 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "7.14.5", | ||
"@babel/core": "7.14.8", | ||
"@babel/helper-plugin-test-runner": "7.14.5", | ||
@@ -29,0 +29,0 @@ "@babel/plugin-syntax-jsx": "7.14.5" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3952
55