diff --git a/lib/6to5/transformation/transformers/es6-classes.js b/lib/6to5/transformation/transformers/es6-classes.js index 327b1a8063..62048733fa 100644 --- a/lib/6to5/transformation/transformers/es6-classes.js +++ b/lib/6to5/transformation/transformers/es6-classes.js @@ -89,7 +89,7 @@ Class.prototype.run = function () { this.closure = true; // so we're only evaluating it once - var superRef = t.getUid(superName, this.file); + var superRef = this.scope.generateUidBasedOnNode(superName, this.file); body.unshift(t.variableDeclaration("var", [ t.variableDeclarator(superRef, superName) ])); diff --git a/lib/6to5/transformation/transformers/es6-computed-property-names.js b/lib/6to5/transformation/transformers/es6-computed-property-names.js index 0b6576c3fc..94abf3f4a3 100644 --- a/lib/6to5/transformation/transformers/es6-computed-property-names.js +++ b/lib/6to5/transformation/transformers/es6-computed-property-names.js @@ -1,6 +1,6 @@ var t = require("../../types"); -exports.ObjectExpression = function (node, parent, file) { +exports.ObjectExpression = function (node, parent, file, scope) { var hasComputed = false; var prop; var key; @@ -13,7 +13,7 @@ exports.ObjectExpression = function (node, parent, file) { if (!hasComputed) return; - var objId = t.getUid(parent, file); + var objId = scope.generateUidBasedOnNode(parent, file); var body = []; var container = t.functionExpression(null, [], t.blockStatement(body)); diff --git a/lib/6to5/transformation/transformers/es6-destructuring.js b/lib/6to5/transformation/transformers/es6-destructuring.js index f12264f86b..8858790d77 100644 --- a/lib/6to5/transformation/transformers/es6-destructuring.js +++ b/lib/6to5/transformation/transformers/es6-destructuring.js @@ -75,7 +75,7 @@ var pushArrayPattern = function (opts, nodes, pattern, parentId) { var toArray = opts.file.toArray(parentId, !hasSpreadElement && pattern.elements.length); - var _parentId = t.getUid(parentId, opts.file, opts.scope); + var _parentId = opts.scope.generateUidBasedOnNode(parentId, opts.file); nodes.push(t.variableDeclaration("var", [ t.variableDeclarator(_parentId, toArray) ])); @@ -113,7 +113,7 @@ var pushPattern = function (opts) { var scope = opts.scope; if (!t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) { - var key = t.getUid(parentId, file, scope); + var key = scope.generateUidBasedOnNode(parentId, file); nodes.push(t.variableDeclaration("var", [ t.variableDeclarator(key, parentId) diff --git a/lib/6to5/transformation/transformers/es6-property-method-assignment.js b/lib/6to5/transformation/transformers/es6-property-method-assignment.js index 487441a4fd..035b8839db 100644 --- a/lib/6to5/transformation/transformers/es6-property-method-assignment.js +++ b/lib/6to5/transformation/transformers/es6-property-method-assignment.js @@ -7,7 +7,7 @@ exports.Property = function (node, parent, file, scope) { node.method = false; - var key = t.toComputedPropertyKey(node); + var key = t.toComputedKey(node, node.key); if (!t.isLiteral(key)) return; // we can't set a function id with this var id = t.toIdentifier(key.value); @@ -46,7 +46,7 @@ exports.Property = function (node, parent, file, scope) { } }; -exports.ObjectExpression = function (node, parent, file) { +exports.ObjectExpression = function (node, parent, file, scope) { var mutatorMap = {}; var hasAny = false; @@ -63,7 +63,7 @@ exports.ObjectExpression = function (node, parent, file) { if (!hasAny) return; if (node.properties.length) { - var objId = t.getUid(parent, file); + var objId = scope.generateUidBasedOnNode(parent, file); return util.template("object-define-properties-closure", { KEY: objId, diff --git a/lib/6to5/transformation/transformers/es6-spread.js b/lib/6to5/transformation/transformers/es6-spread.js index e3b13c8bdc..2415cc8a8c 100644 --- a/lib/6to5/transformation/transformers/es6-spread.js +++ b/lib/6to5/transformation/transformers/es6-spread.js @@ -77,16 +77,13 @@ exports.CallExpression = function (node, parent, file, scope) { } var callee = node.callee; - var temp; if (t.isMemberExpression(callee)) { - contextLiteral = callee.object; - - if (t.isDynamic(contextLiteral)) { - temp = contextLiteral = scope.generateTemp(file); + var temp = scope.generateTempBasedOnNode(callee.object, file); + if (temp) { callee.object = t.assignmentExpression("=", temp, callee.object); + contextLiteral = temp; } - t.appendToMemberExpression(callee, t.identifier("apply")); } else { node.callee = t.memberExpression(node.callee, t.identifier("apply")); diff --git a/lib/6to5/transformation/transformers/es7-abstract-references.js b/lib/6to5/transformation/transformers/es7-abstract-references.js index f6fa4510ba..89bc7c05e4 100644 --- a/lib/6to5/transformation/transformers/es7-abstract-references.js +++ b/lib/6to5/transformation/transformers/es7-abstract-references.js @@ -30,10 +30,8 @@ exports.AssignmentExpression = function (node, parent, file, scope) { // we need to return `node.right` if (!t.isExpressionStatement(parent)) { - // `node.right` isn't a simple identifier so we need to reference it - if (t.isDynamic(value)) { - temp = value = scope.generateTemp(file); - } + temp = scope.generateTempBasedOnNode(node.right, file); + if (temp) value = temp; } if (node.operator !== "=") { @@ -80,11 +78,7 @@ exports.CallExpression = function (node, parent, file, scope) { var callee = node.callee; if (!t.isVirtualPropertyExpression(callee)) return; - var temp; - if (t.isDynamic(callee.object)) { - // we need to save `callee.object` so we can call it again - temp = scope.generateTemp(file); - } + var temp = scope.generateTempBasedOnNode(callee.object, file); var call = util.template("abstract-expression-call", { PROPERTY: callee.property, diff --git a/lib/6to5/transformation/transformers/es7-array-comprehension.js b/lib/6to5/transformation/transformers/es7-array-comprehension.js index 1f9ab8ebfb..becf836007 100644 --- a/lib/6to5/transformation/transformers/es7-array-comprehension.js +++ b/lib/6to5/transformation/transformers/es7-array-comprehension.js @@ -5,7 +5,7 @@ var t = require("../../types"); exports.experimental = true; var build = function (node, parent, file, scope) { - var uid = t.getUid(parent, file, scope); + var uid = scope.generateUidBasedOnNode(parent, file); var container = util.template("array-comprehension-container", { KEY: uid diff --git a/lib/6to5/transformation/transformers/playground-memoization-operator.js b/lib/6to5/transformation/transformers/playground-memoization-operator.js index f9411c8d00..c8cf35b4d8 100644 --- a/lib/6to5/transformation/transformers/playground-memoization-operator.js +++ b/lib/6to5/transformation/transformers/playground-memoization-operator.js @@ -10,7 +10,7 @@ var getPropRef = function (nodes, prop, file, scope) { if (t.isIdentifier(prop)) { return t.literal(prop.name); } else { - var temp = t.getUid(prop, file, scope); + var temp = scope.generateUidBasedOnNode(prop, file); nodes.push(t.variableDeclaration("var", [ t.variableDeclarator(temp, prop) ])); @@ -19,15 +19,11 @@ var getPropRef = function (nodes, prop, file, scope) { }; var getObjRef = function (nodes, obj, file, scope) { - if (t.isDynamic(obj)) { - var temp = t.getUid(obj, file, scope); - nodes.push(t.variableDeclaration("var", [ - t.variableDeclarator(temp, obj) - ])); - return temp; - } else { - return obj; - } + var temp = scope.generateUidBasedOnNode(obj, file); + nodes.push(t.variableDeclaration("var", [ + t.variableDeclarator(temp, obj) + ])); + return temp; }; var buildHasOwn = function (obj, prop, file) { diff --git a/lib/6to5/transformation/transformers/playground-method-binding.js b/lib/6to5/transformation/transformers/playground-method-binding.js index 435f01e8d3..c14bd6dc3b 100644 --- a/lib/6to5/transformation/transformers/playground-method-binding.js +++ b/lib/6to5/transformation/transformers/playground-method-binding.js @@ -5,10 +5,8 @@ exports.BindMemberExpression = function (node, parent, file, scope) { var object = node.object; var prop = node.property; - var temp; - if (t.isDynamic(object)) { - temp = object = scope.generateTemp(file); - } + var temp = scope.generateTempBasedOnNode(node.object, file); + if (temp) object = temp; var call = t.callExpression( t.memberExpression(t.memberExpression(object, prop), t.identifier("bind")), @@ -33,16 +31,12 @@ exports.BindFunctionExpression = function (node, parent, file, scope) { ])); }; - if (_.find(node.arguments, t.isDynamic)) { - var temp = scope.generateTemp(file, "args"); + var temp = scope.generateTemp(file, "args"); - return t.sequenceExpression([ - t.assignmentExpression("=", temp, t.arrayExpression(node.arguments)), - buildCall(node.arguments.map(function (node, i) { - return t.memberExpression(temp, t.literal(i), true); - })) - ]); - } else { - return buildCall(node.arguments); - } + return t.sequenceExpression([ + t.assignmentExpression("=", temp, t.arrayExpression(node.arguments)), + buildCall(node.arguments.map(function (node, i) { + return t.memberExpression(temp, t.literal(i), true); + })) + ]); }; diff --git a/lib/6to5/traverse/scope.js b/lib/6to5/traverse/scope.js index 7ec5f645af..f6cc050998 100644 --- a/lib/6to5/traverse/scope.js +++ b/lib/6to5/traverse/scope.js @@ -31,6 +31,13 @@ Scope.add = function (node, references) { _.defaults(references, t.getIds(node, true)); }; +/** + * Description + * + * @param {File} file + * @param {String} [name="temp"] + */ + Scope.prototype.generateTemp = function (file, name) { var id = file.generateUidIdentifier(name || "temp", this); this.push({ @@ -40,6 +47,83 @@ Scope.prototype.generateTemp = function (file, name) { return id; }; +/* + * Description + * + * @param {Object} parent + * @param {File} file + * @param {Scope} scope + * @returns {Object} + */ + +Scope.prototype.generateUidBasedOnNode = function (parent, file) { + var node = parent; + + if (t.isAssignmentExpression(parent)) { + node = parent.left; + } else if (t.isVariableDeclarator(parent)) { + node = parent.id; + } + + var id = "ref"; + + if (t.isProperty(node)) { + node = node.key; + } + + if (t.isIdentifier(node)) { + id = node.name; + } else if (t.isLiteral(node)) { + id = node.value; + } else if (t.isMemberExpression(node)) { + var parts = []; + + var add = function (node) { + if (t.isMemberExpression(node)) { + add(node.object); + add(node.property); + } else if (t.isIdentifier(node)) { + parts.push(node.name); + } else if (t.isLiteral(node)) { + parts.push(node.value); + } + }; + + add(node); + + id = parts.join("$"); + } + + id = id.replace(/^_/, ""); + + return file.generateUidIdentifier(id, this); +}; + +/** + * Description + * + * @param {Object} node + * @param {File} file + * @returns {Object} + */ + +Scope.prototype.generateTempBasedOnNode = function (node, file) { + if (!t.isIdentifier(node) && !t.isMemberExpression(node)) { + throw new TypeError("Invalid node type " + JSON.stringify(node.type) + " passed to Scope.prototype.generateTempBasedOnNode"); + } + + if (t.isIdentifier(node) && this.has(node.name, true)) { + return null; + } + + var id = this.generateUidBasedOnNode(node, file); + this.push({ + key: id.name, + id: id + }); + return id; +}; + Scope.prototype.getInfo = function () { var block = this.block; if (block._scopeInfo) return block._scopeInfo; @@ -123,6 +207,12 @@ Scope.prototype.getInfo = function () { return info; }; +/** + * Description + * + * @param {Object} opts + */ + Scope.prototype.push = function (opts) { var block = this.block; @@ -143,33 +233,84 @@ Scope.prototype.push = function (opts) { } }; +/** + * Description + * + * @param {Object} node + */ + Scope.prototype.add = function (node) { Scope.add(node, this.references); }; +/** + * Description + * + * @param {String} [id] + * @param {Boolean} [decl] + */ + Scope.prototype.get = function (id, decl) { return id && (this.getOwn(id, decl) || this.parentGet(id, decl)); }; +/** + * Description + * + * @param {String} [id] + * @param {Boolean} [decl] + */ + Scope.prototype.getOwn = function (id, decl) { var refs = this.references; if (decl) refs = this.declarations; return _.has(refs, id) && refs[id]; }; +/** + * Description + * + * @param {String} [id] + * @param {Boolean} [decl] + */ + Scope.prototype.parentGet = function (id, decl) { return this.parent && this.parent.get(id, decl); }; +/** + * Description + * + * @param {String} [id] + * @param {Boolean} [decl] + * @returns {Boolean} + */ + Scope.prototype.has = function (id, decl) { return (id && (this.hasOwn(id, decl) || this.parentHas(id, decl))) || _.contains(Scope.defaultDeclarations, id); }; +/** + * Description + * + * @param {String} [id] + * @param {Boolean} [decl] + * @returns {Boolean} + */ + Scope.prototype.hasOwn = function (id, decl) { return !!this.getOwn(id, decl); }; +/** + * Description + * + * @param {String} [id] + * @param {Boolean} [decl] + * @returns {Boolean} + */ + Scope.prototype.parentHas = function (id, decl) { return this.parent && this.parent.has(id, decl); }; diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index b796767370..a196d4bfed 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -71,9 +71,8 @@ _.each(t.FLIPPED_ALIAS_KEYS, function (types, type) { * @returns {Object} */ -t.toComputedPropertyKey = function (prop) { - var key = prop.key; - if (!prop.computed) { +t.toComputedKey = function (node, key) { + if (!node.computed) { if (t.isIdentifier(key)) key = t.literal(key.name); } return key; @@ -126,6 +125,10 @@ t.toSequenceExpression = function (nodes, scope) { } }); + if (exprs.length === 1) { + return exprs[0] + } + return t.sequenceExpression(exprs); }; @@ -174,25 +177,6 @@ t.prependToMemberExpression = function (member, append) { return member; }; -/* - * Description - * - * @param {Object} node - * @returns {Boolean} - */ - -t.isDynamic = function (node) { - if (t.isExpressionStatement(node)) { - return t.isDynamic(node.expression); - } else if (t.isIdentifier(node) || t.isLiteral(node) || t.isThisExpression(node)) { - return false; - } else if (t.isMemberExpression(node)) { - return t.isDynamic(node.object) || t.isDynamic(node.property); - } else { - return true; - } -}; - /** * Description * @@ -341,58 +325,6 @@ t.toBlock = function (node, parent) { return t.blockStatement(node); }; -/* - * Description - * - * @param {Object} parent - * @param {File} file - * @param {Scope} scope - * @returns {Object} - */ - -t.getUid = function (parent, file, scope) { - var node = parent; - - if (t.isAssignmentExpression(parent)) { - node = parent.left; - } else if (t.isVariableDeclarator(parent)) { - node = parent.id; - } - - var id = "ref"; - - if (t.isProperty(node)) { - node = node.key; - } - - if (t.isIdentifier(node)) { - id = node.name; - } else if (t.isLiteral(node)) { - id = node.value; - } else if (t.isMemberExpression(node)) { - var parts = []; - - var add = function (node) { - if (t.isMemberExpression(node)) { - add(node.object); - add(node.property); - } else if (t.isIdentifier(node)) { - parts.push(node.name); - } else if (t.isLiteral(node)) { - parts.push(node.value); - } - }; - - add(node); - - id = parts.join("$"); - } - - id = id.replace(/^_/, ""); - - return file.generateUidIdentifier(id, scope); -}; - /** * Description * diff --git a/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js b/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js index 028865cfc7..1eec391c5e 100644 --- a/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js +++ b/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js @@ -16,30 +16,33 @@ var _inherits = function (child, parent) { var Test = (function () { var _Foo = Foo; var Test = function Test() { + var _Foo$prototype$test, _Foo$prototype$test2; woops["super"].test(); _Foo.call(this); _Foo.prototype.test.call(this); foob(_Foo); - _Foo.call.apply(_Foo, [this].concat(_slice.call(arguments))); - _Foo.call.apply(_Foo, [this, "test"].concat(_slice.call(arguments))); + _Foo.call.apply(null, [this].concat(_slice.call(arguments))); + _Foo.call.apply(null, [this, "test"].concat(_slice.call(arguments))); - _Foo.prototype.test.call.apply(_Foo.prototype.test, [this].concat(_slice.call(arguments))); - _Foo.prototype.test.call.apply(_Foo.prototype.test, [this, "test"].concat(_slice.call(arguments))); + (_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments))); + (_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments))); }; _inherits(Test, _Foo); Test.prototype.test = function () { + var _Foo$prototype$test3, _Foo$prototype$test4; _Foo.prototype.test.call(this); - _Foo.prototype.test.call.apply(_Foo.prototype.test, [this].concat(_slice.call(arguments))); - _Foo.prototype.test.call.apply(_Foo.prototype.test, [this, "test"].concat(_slice.call(arguments))); + (_Foo$prototype$test3 = _Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments))); + (_Foo$prototype$test4 = _Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments))); }; Test.foo = function () { + var _Foo$foo, _Foo$foo2; _Foo.foo.call(this); - _Foo.foo.call.apply(_Foo.foo, [this].concat(_slice.call(arguments))); - _Foo.foo.call.apply(_Foo.foo, [this, "test"].concat(_slice.call(arguments))); + (_Foo$foo = _Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments))); + (_Foo$foo2 = _Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments))); }; return Test; diff --git a/test/fixtures/transformation/es6-spread/contexted-computed-method-call-multiple-args/expected.js b/test/fixtures/transformation/es6-spread/contexted-computed-method-call-multiple-args/expected.js index ba53baf642..2df1266ea6 100644 --- a/test/fixtures/transformation/es6-spread/contexted-computed-method-call-multiple-args/expected.js +++ b/test/fixtures/transformation/es6-spread/contexted-computed-method-call-multiple-args/expected.js @@ -1,7 +1,8 @@ "use strict"; +var _obj; var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr); }; -obj[method].apply(obj, [foo, bar].concat(_toArray(args))); +(_obj = obj)[method].apply(_obj, [foo, bar].concat(_toArray(args))); diff --git a/test/fixtures/transformation/es6-spread/contexted-computed-method-call-single-arg/expected.js b/test/fixtures/transformation/es6-spread/contexted-computed-method-call-single-arg/expected.js index 1fffa64593..787118ee8d 100644 --- a/test/fixtures/transformation/es6-spread/contexted-computed-method-call-single-arg/expected.js +++ b/test/fixtures/transformation/es6-spread/contexted-computed-method-call-single-arg/expected.js @@ -1,7 +1,8 @@ "use strict"; +var _obj; var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr); }; -obj[method].apply(obj, _toArray(args)); +(_obj = obj)[method].apply(_obj, _toArray(args)); diff --git a/test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js b/test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js index 9059837291..4286bae62f 100644 --- a/test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js +++ b/test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js @@ -1,8 +1,9 @@ "use strict"; +var _foob, _foob$test; var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr); }; -foob.add.apply(foob, [foo, bar].concat(_toArray(numbers))); -foob.test.add.apply(foob.test, [foo, bar].concat(_toArray(numbers))); +(_foob = foob).add.apply(_foob, [foo, bar].concat(_toArray(numbers))); +(_foob$test = foob.test).add.apply(_foob$test, [foo, bar].concat(_toArray(numbers))); diff --git a/test/fixtures/transformation/es6-spread/contexted-method-call-single-arg/expected.js b/test/fixtures/transformation/es6-spread/contexted-method-call-single-arg/expected.js index 0b249435e2..ea00630a64 100644 --- a/test/fixtures/transformation/es6-spread/contexted-method-call-single-arg/expected.js +++ b/test/fixtures/transformation/es6-spread/contexted-method-call-single-arg/expected.js @@ -1,8 +1,9 @@ "use strict"; +var _foob, _foob$test; var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr); }; -foob.add.apply(foob, _toArray(numbers)); -foob.test.add.apply(foob.test, _toArray(numbers)); +(_foob = foob).add.apply(_foob, _toArray(numbers)); +(_foob$test = foob.test).add.apply(_foob$test, _toArray(numbers)); diff --git a/test/fixtures/transformation/es7-abstract-references/call/actual.js b/test/fixtures/transformation/es7-abstract-references/call/actual.js index ced7e8054a..51355b9a69 100644 --- a/test/fixtures/transformation/es7-abstract-references/call/actual.js +++ b/test/fixtures/transformation/es7-abstract-references/call/actual.js @@ -1,2 +1,6 @@ foo::bar(); foo::bar("arg"); + +var test = "test"; +test::bar(); +test::bar("arg"); diff --git a/test/fixtures/transformation/es7-abstract-references/call/expected.js b/test/fixtures/transformation/es7-abstract-references/call/expected.js index 9906be863c..4a2d6e1482 100644 --- a/test/fixtures/transformation/es7-abstract-references/call/expected.js +++ b/test/fixtures/transformation/es7-abstract-references/call/expected.js @@ -1,4 +1,9 @@ "use strict"; -bar[Symbol.referenceGet](foo).call(foo); -bar[Symbol.referenceGet](foo).call(foo, "arg"); +var _foo, _foo2; +_foo = foo, bar[Symbol.referenceGet](_foo).call(_foo); +_foo2 = foo, bar[Symbol.referenceGet](_foo2).call(_foo2, "arg"); + +var test = "test"; +bar[Symbol.referenceGet](test).call(test); +bar[Symbol.referenceGet](test).call(test, "arg"); diff --git a/test/fixtures/transformation/es7-abstract-references/delete/actual.js b/test/fixtures/transformation/es7-abstract-references/delete/actual.js index 47c17e0269..af9f86c23c 100644 --- a/test/fixtures/transformation/es7-abstract-references/delete/actual.js +++ b/test/fixtures/transformation/es7-abstract-references/delete/actual.js @@ -1,3 +1,3 @@ delete foo::bar; -if (delete foo::bar); +if (delete foo::bar) {} diff --git a/test/fixtures/transformation/es7-abstract-references/delete/expected.js b/test/fixtures/transformation/es7-abstract-references/delete/expected.js index 38b7e10af1..489c0b7863 100644 --- a/test/fixtures/transformation/es7-abstract-references/delete/expected.js +++ b/test/fixtures/transformation/es7-abstract-references/delete/expected.js @@ -2,4 +2,4 @@ bar[Symbol.referenceDelete](foo); -if ((bar[Symbol.referenceDelete](foo), true)) ; +if ((bar[Symbol.referenceDelete](foo), true)) {} diff --git a/test/fixtures/transformation/es7-abstract-references/set/actual.js b/test/fixtures/transformation/es7-abstract-references/set/actual.js index 3f18c6b93b..8abf694209 100644 --- a/test/fixtures/transformation/es7-abstract-references/set/actual.js +++ b/test/fixtures/transformation/es7-abstract-references/set/actual.js @@ -1,2 +1,3 @@ +var baz = "foo"; foo::bar = baz; -if (foo::bar = baz); +if (foo::bar = baz) {} diff --git a/test/fixtures/transformation/es7-abstract-references/set/expected.js b/test/fixtures/transformation/es7-abstract-references/set/expected.js index fd1b67fb34..be9e6ef9f3 100644 --- a/test/fixtures/transformation/es7-abstract-references/set/expected.js +++ b/test/fixtures/transformation/es7-abstract-references/set/expected.js @@ -1,4 +1,5 @@ "use strict"; +var baz = "foo"; bar[Symbol.referenceSet](foo, baz); -if ((bar[Symbol.referenceSet](foo, baz), baz)) ; +if ((bar[Symbol.referenceSet](foo, baz), baz)) {} diff --git a/test/fixtures/transformation/playground/memoization-assignment-operator/expected.js b/test/fixtures/transformation/playground/memoization-assignment-operator/expected.js index de72bd3e59..4d9647c912 100644 --- a/test/fixtures/transformation/playground/memoization-assignment-operator/expected.js +++ b/test/fixtures/transformation/playground/memoization-assignment-operator/expected.js @@ -1,25 +1,27 @@ "use strict"; -var _ref2, _obj2, _ref4; +var _obj2, _obj4, _ref2, _obj6, _ref4; var _hasOwn = Object.prototype.hasOwnProperty; var obj = {}; -if (!_hasOwn.call(obj, "x")) obj.x = 2; +var _obj = obj; +if (!_hasOwn.call(_obj, "x")) _obj.x = 2; -console.log((!_hasOwn.call(obj, "x") && (obj.x = 2), obj.x)); +console.log((_obj2 = obj, !_hasOwn.call(_obj2, "x") && (_obj2.x = 2), _obj2.x)); +var _obj3 = obj; var _ref = x(); -if (!_hasOwn.call(obj, _ref)) obj[_ref] = 2; +if (!_hasOwn.call(_obj3, _ref)) _obj3[_ref] = 2; -console.log((_ref2 = x(), !_hasOwn.call(obj, _ref2) && (obj[_ref2] = 2), obj[_ref2])); +console.log((_obj4 = obj, _ref2 = x(), !_hasOwn.call(_obj4, _ref2) && (_obj4[_ref2] = 2), _obj4[_ref2])); -var _obj = obj[y()]; +var _obj5 = obj[y()]; var _ref3 = x(); -if (!_hasOwn.call(_obj, _ref3)) _obj[_ref3] = 2; +if (!_hasOwn.call(_obj5, _ref3)) _obj5[_ref3] = 2; -console.log((_obj2 = obj[y()], _ref4 = x(), !_hasOwn.call(_obj2, _ref4) && (_obj2[_ref4] = 2), _obj2[_ref4])); +console.log((_obj6 = obj[y()], _ref4 = x(), !_hasOwn.call(_obj6, _ref4) && (_obj6[_ref4] = 2), _obj6[_ref4])); diff --git a/test/fixtures/transformation/playground/method-binding/expected.js b/test/fixtures/transformation/playground/method-binding/expected.js index 9e811ba21e..f103f4683f 100644 --- a/test/fixtures/transformation/playground/method-binding/expected.js +++ b/test/fixtures/transformation/playground/method-binding/expected.js @@ -1,22 +1,22 @@ "use strict"; -var _temp, _args; -var fn = obj.method.bind(obj); -var fn = obj.method.bind(obj, "foob"); -var fn = obj[foo].method.bind(obj[foo]); -var fn = obj.foo.method.bind(obj.foo); -var fn = (_temp = obj[foo()], _temp.method.bind(_temp)); +var _obj, _obj2, _obj$foo, _obj$foo2, _obj3, _args, _args2, _args3; +var fn = (_obj = obj, _obj.method.bind(_obj)); +var fn = (_obj2 = obj, _obj2.method.bind(_obj2, "foob")); +var fn = (_obj$foo = obj[foo], _obj$foo.method.bind(_obj$foo)); +var fn = (_obj$foo2 = obj.foo, _obj$foo2.method.bind(_obj$foo2)); +var fn = (_obj3 = obj[foo()], _obj3.method.bind(_obj3)); -["foo", "bar"].map(function (_val) { +["foo", "bar"].map((_args = [], function (_val) { return _val.toUpperCase(); -}); -[1.1234, 23.53245, 3].map(function (_val2) { - return _val2.toFixed(2); -}); +})); +[1.1234, 23.53245, 3].map((_args2 = [2], function (_val2) { + return _val2.toFixed(_args2[0]); +})); var get = function () { return 2; }; -[1.1234, 23.53245, 3].map((_args = [get()], function (_val3) { - return _val3.toFixed(_args[0]); +[1.1234, 23.53245, 3].map((_args3 = [get()], function (_val3) { + return _val3.toFixed(_args3[0]); }));