@babel/plugin-transform-react-jsx-self
Advanced tools
Comparing version 7.18.6 to 7.21.0
@@ -7,12 +7,7 @@ "use strict"; | ||
exports.default = void 0; | ||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); | ||
var _core = require("@babel/core"); | ||
const TRACE_ID = "__self"; | ||
function getThisFunctionParent(path) { | ||
let scope = path.scope; | ||
do { | ||
@@ -22,3 +17,2 @@ const { | ||
} = scope; | ||
if (path.isFunctionParent() && !path.isArrowFunctionExpression()) { | ||
@@ -28,28 +22,20 @@ return 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 => { | ||
@@ -62,12 +48,7 @@ api.assertVersion(7); | ||
} | ||
const node = path.node; | ||
const id = _core.types.jsxIdentifier(TRACE_ID); | ||
const trace = _core.types.thisExpression(); | ||
node.attributes.push(_core.types.jsxAttribute(id, _core.types.jsxExpressionContainer(trace))); | ||
} | ||
}; | ||
@@ -80,7 +61,7 @@ return { | ||
} | ||
} | ||
}; | ||
}); | ||
exports.default = _default; | ||
exports.default = _default; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/plugin-transform-react-jsx-self", | ||
"version": "7.18.6", | ||
"version": "7.21.0", | ||
"description": "Add a __self prop to all JSX Elements", | ||
@@ -20,3 +20,3 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "^7.18.6" | ||
"@babel/helper-plugin-utils": "^7.20.2" | ||
}, | ||
@@ -27,3 +27,3 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@babel/core": "^7.18.6", | ||
"@babel/core": "^7.21.0", | ||
"@babel/helper-plugin-test-runner": "^7.18.6", | ||
@@ -30,0 +30,0 @@ "@babel/plugin-syntax-jsx": "^7.18.6" |
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
8927
5
60