@babel/plugin-transform-react-constant-elements
Advanced tools
Comparing version 7.20.2 to 7.21.3
@@ -17,3 +17,2 @@ "use strict"; | ||
} | ||
const HOISTED = new WeakMap(); | ||
@@ -60,3 +59,2 @@ function declares(node, scope) { | ||
if (scope === state.targetScope) return; | ||
if (declares(node, scope)) break; | ||
@@ -77,4 +75,6 @@ scope = scope.parent; | ||
}; | ||
if (path.isJSXClosingElement()) return skip(); | ||
if (path.isJSXClosingElement()) { | ||
skip(); | ||
return; | ||
} | ||
if (path.isJSXIdentifier({ | ||
@@ -85,9 +85,8 @@ name: "ref" | ||
})) { | ||
return stop(); | ||
stop(); | ||
return; | ||
} | ||
if (path.isJSXIdentifier() || path.isJSXMemberExpression() || path.isJSXNamespacedName() || path.isImmutable()) { | ||
return; | ||
} | ||
if (path.isIdentifier()) { | ||
@@ -97,3 +96,2 @@ const binding = path.scope.getBinding(path.node.name); | ||
} | ||
const { | ||
@@ -104,6 +102,9 @@ mutablePropsAllowed | ||
path.traverse(targetScopeVisitor, state); | ||
return skip(); | ||
skip(); | ||
return; | ||
} | ||
if (!path.isPure()) return stop(); | ||
if (!path.isPure()) { | ||
stop(); | ||
return; | ||
} | ||
const expressionResult = path.evaluate(); | ||
@@ -115,3 +116,4 @@ if (expressionResult.confident) { | ||
if (mutablePropsAllowed || value === null || typeof value !== "object" && typeof value !== "function") { | ||
return skip(); | ||
skip(); | ||
return; | ||
} | ||
@@ -124,3 +126,2 @@ } else if (_core.types.isIdentifier(expressionResult.deopt)) { | ||
}; | ||
const hoistingVisitor = Object.assign({}, immutabilityVisitor, targetScopeVisitor); | ||
@@ -134,3 +135,2 @@ return { | ||
const name = path.node.openingElement.name; | ||
let mutablePropsAllowed = false; | ||
@@ -145,3 +145,2 @@ if (allowMutablePropsOnTags != null) { | ||
} | ||
let jsxScope; | ||
@@ -148,0 +147,0 @@ let current = path; |
{ | ||
"name": "@babel/plugin-transform-react-constant-elements", | ||
"version": "7.20.2", | ||
"version": "7.21.3", | ||
"description": "Treat React JSX elements as value types and hoist them to the highest scope", | ||
@@ -26,3 +26,3 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.20.2", | ||
"@babel/core": "^7.21.3", | ||
"@babel/helper-plugin-test-runner": "^7.18.6" | ||
@@ -29,0 +29,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
23287
179