@babel/plugin-transform-block-scoping
Advanced tools
Comparing version 7.20.9 to 7.20.11
@@ -54,10 +54,11 @@ "use strict"; | ||
const names = Object.keys(headPath.getBindingIdentifiers()); | ||
for (const name of names) { | ||
const headScope = headPath.scope; | ||
for (let name of names) { | ||
var _bodyScope; | ||
if ((_bodyScope = bodyScope) != null && _bodyScope.hasOwnBinding(name)) continue; | ||
let binding = headPath.scope.getOwnBinding(name); | ||
let binding = headScope.getOwnBinding(name); | ||
if (!binding) { | ||
headPath.scope.crawl(); | ||
binding = headPath.scope.getOwnBinding(name); | ||
headScope.crawl(); | ||
binding = headScope.getOwnBinding(name); | ||
} | ||
@@ -72,2 +73,6 @@ const { | ||
captured.push(name); | ||
} else if (headScope.parent.hasBinding(name)) { | ||
const newName = headScope.generateUid(name); | ||
headPath.scope.rename(name, newName); | ||
name = newName; | ||
} | ||
@@ -74,0 +79,0 @@ if (isForStatement && hasConstantViolations) { |
@@ -155,9 +155,4 @@ "use strict"; | ||
const updater = []; | ||
for (const name of captured) { | ||
for (const [name, updatedUsage] of updatedBindingsUsages) { | ||
callArgs.push(_core.types.identifier(name)); | ||
const updatedUsage = updatedBindingsUsages.get(name); | ||
if (!updatedUsage) { | ||
closureParams.push(_core.types.identifier(name)); | ||
continue; | ||
} | ||
const innerName = loopPath.scope.generateUid(name); | ||
@@ -168,2 +163,7 @@ closureParams.push(_core.types.identifier(innerName)); | ||
} | ||
for (const name of captured) { | ||
if (updatedBindingsUsages.has(name)) continue; | ||
callArgs.push(_core.types.identifier(name)); | ||
closureParams.push(_core.types.identifier(name)); | ||
} | ||
const id = loopPath.scope.generateUid("loop"); | ||
@@ -170,0 +170,0 @@ const fn = _core.types.functionExpression(null, closureParams, _core.types.toBlock(loopNode.body)); |
{ | ||
"name": "@babel/plugin-transform-block-scoping", | ||
"version": "7.20.9", | ||
"version": "7.20.11", | ||
"description": "Compile ES2015 block scoping (const and let) to ES5", | ||
@@ -28,3 +28,3 @@ "repository": { | ||
"@babel/helper-plugin-test-runner": "^7.18.6", | ||
"@babel/traverse": "^7.20.8" | ||
"@babel/traverse": "^7.20.10" | ||
}, | ||
@@ -31,0 +31,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
83943
687