@babel/plugin-proposal-object-rest-spread
Advanced tools
Comparing version 7.7.4 to 7.7.7
@@ -109,10 +109,10 @@ "use strict"; | ||
function replaceImpureComputedKeys(path) { | ||
function replaceImpureComputedKeys(properties, scope) { | ||
const impureComputedPropertyDeclarators = []; | ||
for (const propPath of path.get("properties")) { | ||
for (const propPath of properties) { | ||
const key = propPath.get("key"); | ||
if (propPath.node.computed && !key.isPure()) { | ||
const name = path.scope.generateUidBasedOnNode(key.node); | ||
const name = scope.generateUidBasedOnNode(key.node); | ||
@@ -151,3 +151,3 @@ const declarator = _core.types.variableDeclarator(_core.types.identifier(name), key.node); | ||
last.remove(); | ||
const impureComputedPropertyDeclarators = replaceImpureComputedKeys(path); | ||
const impureComputedPropertyDeclarators = replaceImpureComputedKeys(path.get("properties"), path.scope); | ||
const { | ||
@@ -234,3 +234,3 @@ keys, | ||
if (path.isObjectProperty()) { | ||
refPropertyPath.unshift(path.node.key.name); | ||
refPropertyPath.unshift(path); | ||
} else if (path.isVariableDeclarator()) { | ||
@@ -241,9 +241,9 @@ kind = path.parentPath.node.kind; | ||
}); | ||
if (refPropertyPath.length) { | ||
refPropertyPath.forEach(prop => { | ||
ref = _core.types.memberExpression(ref, _core.types.identifier(prop)); | ||
}); | ||
} | ||
const impureObjRefComputedDeclarators = replaceImpureComputedKeys(refPropertyPath, path.scope); | ||
refPropertyPath.forEach(prop => { | ||
const { | ||
node | ||
} = prop; | ||
ref = _core.types.memberExpression(ref, _core.types.cloneNode(node.key), node.computed); | ||
}); | ||
const objectPatternPath = path.findParent(path => path.isObjectPattern()); | ||
@@ -259,2 +259,3 @@ const [impureComputedPropertyDeclarators, argument, callExpression] = createObjectSpread(objectPatternPath, file, ref); | ||
insertionPath.insertBefore(impureComputedPropertyDeclarators); | ||
insertionPath.insertBefore(impureObjRefComputedDeclarators); | ||
insertionPath.insertAfter(_core.types.variableDeclarator(argument, callExpression)); | ||
@@ -261,0 +262,0 @@ insertionPath = insertionPath.getSibling(insertionPath.key + 1); |
{ | ||
"name": "@babel/plugin-proposal-object-rest-spread", | ||
"version": "7.7.4", | ||
"version": "7.7.7", | ||
"description": "Compile object rest and spread to ES5", | ||
@@ -22,6 +22,6 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-object-rest-spread", | ||
"devDependencies": { | ||
"@babel/core": "^7.7.4", | ||
"@babel/core": "^7.7.7", | ||
"@babel/helper-plugin-test-runner": "^7.7.4" | ||
}, | ||
"gitHead": "75767d87cb147709b9bd9b99bf44daa6688874a9" | ||
"gitHead": "12da0941c898987ae30045a9da90ed5bf58ecaf9" | ||
} |
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
15975
0
321