@babel/helper-create-class-features-plugin
Advanced tools
Comparing version 7.8.3 to 7.8.6
@@ -43,15 +43,16 @@ "use strict"; | ||
const classFieldDefinitionEvaluationTDZVisitor = _core.traverse.visitors.merge([{ | ||
ReferencedIdentifier(path) { | ||
if (this.classBinding && this.classBinding === path.scope.getBinding(path.node.name)) { | ||
const classNameTDZError = this.file.addHelper("classNameTDZError"); | ||
function handleClassTDZ(path, state) { | ||
if (state.classBinding && state.classBinding === path.scope.getBinding(path.node.name)) { | ||
const classNameTDZError = state.file.addHelper("classNameTDZError"); | ||
const throwNode = _core.types.callExpression(classNameTDZError, [_core.types.stringLiteral(path.node.name)]); | ||
const throwNode = _core.types.callExpression(classNameTDZError, [_core.types.stringLiteral(path.node.name)]); | ||
path.replaceWith(_core.types.sequenceExpression([throwNode, path.node])); | ||
path.skip(); | ||
} | ||
path.replaceWith(_core.types.sequenceExpression([throwNode, path.node])); | ||
path.skip(); | ||
} | ||
} | ||
}, _helperReplaceSupers.environmentVisitor]); | ||
const classFieldDefinitionEvaluationTDZVisitor = { | ||
ReferencedIdentifier: handleClassTDZ | ||
}; | ||
@@ -93,11 +94,19 @@ function injectInitialization(path, constructor, nodes, renamer) { | ||
const declarations = []; | ||
const state = { | ||
classBinding: path.node.id && path.scope.getBinding(path.node.id.name), | ||
file | ||
}; | ||
for (const computedPath of computedPaths) { | ||
computedPath.traverse(classFieldDefinitionEvaluationTDZVisitor, { | ||
classBinding: path.node.id && path.scope.getBinding(path.node.id.name), | ||
file | ||
}); | ||
const computedKey = computedPath.get("key"); | ||
if (computedKey.isReferencedIdentifier()) { | ||
handleClassTDZ(computedKey, state); | ||
} else { | ||
computedKey.traverse(classFieldDefinitionEvaluationTDZVisitor, state); | ||
} | ||
const computedNode = computedPath.node; | ||
if (!computedPath.get("key").isConstantExpression()) { | ||
if (!computedKey.isConstantExpression()) { | ||
const ident = path.scope.generateUidIdentifierBasedOnNode(computedNode.key); | ||
@@ -104,0 +113,0 @@ path.scope.push({ |
{ | ||
"name": "@babel/helper-create-class-features-plugin", | ||
"version": "7.8.3", | ||
"version": "7.8.6", | ||
"author": "The Babel Team (https://babeljs.io/team)", | ||
@@ -21,3 +21,3 @@ "license": "MIT", | ||
"@babel/helper-plugin-utils": "^7.8.3", | ||
"@babel/helper-replace-supers": "^7.8.3", | ||
"@babel/helper-replace-supers": "^7.8.6", | ||
"@babel/helper-split-export-declaration": "^7.8.3" | ||
@@ -29,6 +29,6 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.8.3", | ||
"@babel/core": "^7.8.6", | ||
"@babel/helper-plugin-test-runner": "^7.8.3" | ||
}, | ||
"gitHead": "a7620bd266ae1345975767bbc7abf09034437017" | ||
"gitHead": "750d3dde3bd2d390819820fd22c05441da78751b" | ||
} |
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
39519
996