Avoid repeating impure (template) literals when desugaring **= (#4403) (#4672)

This commit is contained in:
Moti Zilberman 2016-10-05 12:10:12 +03:00 committed by Daniel Tschinder
parent 9e17aaf043
commit f5b5d8f337
4 changed files with 9 additions and 1 deletions

View File

@ -41,7 +41,7 @@ function getObjRef(node, nodes, file, scope) {
function getPropRef(node, nodes, file, scope) {
let prop = node.property;
let key = t.toComputedKey(node, prop);
if (t.isLiteral(key)) return key;
if (t.isLiteral(key) && t.isPureish(key)) return key;
let temp = scope.generateUidIdentifierBasedOnNode(prop);
nodes.push(t.variableDeclaration("var", [

View File

@ -0,0 +1,2 @@
var a, b;
a[`${b++}`] **= 1;

View File

@ -0,0 +1,3 @@
var a, b;
var _ref = `${ b++ }`;
a[_ref] = Math.pow(a[_ref], 1)

View File

@ -0,0 +1,3 @@
{
"plugins": ["transform-exponentiation-operator"]
}