From 93ceafc7326958e31c708a5ee9ab1d6064d2590d Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 2 Jan 2015 03:53:28 +1100 Subject: [PATCH] better uid names --- .../es5-property-method-assignment.js | 2 +- .../transformers/es6-classes.js | 6 +-- .../es6-computed-property-names.js | 2 +- .../transformers/es6-destructuring.js | 7 +-- .../transformers/es7-array-comprehension.js | 8 ++-- .../playground-memoization-operator.js | 4 +- lib/6to5/types/index.js | 48 ++++++++++++++++++- lib/6to5/util.js | 16 ------- .../accessing-super-class/expected.js | 30 ++++++------ .../accessing-super-properties/expected.js | 8 ++-- .../calling-super-properties/expected.js | 10 ++-- .../es6-classes/constructor/expected.js | 4 +- .../expected.js | 16 +++---- .../es6-classes/super-class/expected.js | 8 ++-- .../es6-constants/destructuring/expected.js | 18 +++---- .../es6-destructuring/array/expected.js | 8 ++-- .../assignment-expression/expected.js | 4 +- .../es6-destructuring/empty/expected.js | 8 ++-- .../es6-destructuring/mixed/expected.js | 12 ++--- .../es6-destructuring/parameters/expected.js | 18 +++---- .../arguments/expected.js | 6 +-- .../multiple-if/expected.js | 6 +-- .../es7-array-comprehension/this/expected.js | 6 +-- .../es6-destructuring/expected.js | 8 ++-- .../expected.js | 14 +++--- 25 files changed, 153 insertions(+), 124 deletions(-) diff --git a/lib/6to5/transformation/transformers/es5-property-method-assignment.js b/lib/6to5/transformation/transformers/es5-property-method-assignment.js index a8a22ebba9..e31edbfbfd 100644 --- a/lib/6to5/transformation/transformers/es5-property-method-assignment.js +++ b/lib/6to5/transformation/transformers/es5-property-method-assignment.js @@ -21,7 +21,7 @@ exports.ObjectExpression = function (node, parent, file) { if (!hasAny) return; if (node.properties.length) { - var objId = util.getUid(parent, file); + var objId = t.getUid(parent, file); return util.template("object-define-properties-closure", { KEY: objId, diff --git a/lib/6to5/transformation/transformers/es6-classes.js b/lib/6to5/transformation/transformers/es6-classes.js index e405ab761d..7a63b42f13 100644 --- a/lib/6to5/transformation/transformers/es6-classes.js +++ b/lib/6to5/transformation/transformers/es6-classes.js @@ -87,11 +87,9 @@ Class.prototype.run = function () { if (superName) { this.closure = true; - // so we're only evaluating it once - var superRefName = "super"; - if (className) superRefName = className.name + "Super"; - var superRef = file.generateUidIdentifier(superRefName, this.scope); + // so we're only evaluating it once + var superRef = t.getUid(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 fda19dda7f..f25fb4e04e 100644 --- a/lib/6to5/transformation/transformers/es6-computed-property-names.js +++ b/lib/6to5/transformation/transformers/es6-computed-property-names.js @@ -14,7 +14,7 @@ exports.ObjectExpression = function (node, parent, file) { if (!hasComputed) return; - var objId = util.getUid(parent, file); + var objId = t.getUid(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 2632fb246f..3908f1c57e 100644 --- a/lib/6to5/transformation/transformers/es6-destructuring.js +++ b/lib/6to5/transformation/transformers/es6-destructuring.js @@ -1,6 +1,7 @@ // TODO: Clean up -var t = require("../../types"); +var util = require("../../util"); +var t = require("../../types"); var buildVariableAssign = function (opts, id, init) { var op = opts.operator; @@ -75,7 +76,7 @@ var pushArrayPattern = function (opts, nodes, pattern, parentId) { var toArray = opts.file.toArray(parentId, !hasSpreadElement && pattern.elements.length); - var _parentId = opts.file.generateUidIdentifier("ref", opts.scope); + var _parentId = t.getUid(parentId, opts.file, opts.scope); nodes.push(t.variableDeclaration("var", [ t.variableDeclarator(_parentId, toArray) ])); @@ -113,7 +114,7 @@ var pushPattern = function (opts) { var scope = opts.scope; if (!t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) { - var key = file.generateUidIdentifier("ref", scope); + var key = t.getUid(parentId, file, scope); nodes.push(t.variableDeclaration("var", [ t.variableDeclarator(key, parentId) diff --git a/lib/6to5/transformation/transformers/es7-array-comprehension.js b/lib/6to5/transformation/transformers/es7-array-comprehension.js index 9e3d5bfff1..1f9ab8ebfb 100644 --- a/lib/6to5/transformation/transformers/es7-array-comprehension.js +++ b/lib/6to5/transformation/transformers/es7-array-comprehension.js @@ -4,8 +4,8 @@ var t = require("../../types"); exports.experimental = true; -var build = function (node, file) { - var uid = file.generateUidIdentifier("arr"); +var build = function (node, parent, file, scope) { + var uid = t.getUid(parent, file, scope); var container = util.template("array-comprehension-container", { KEY: uid @@ -55,8 +55,8 @@ exports._build = function (node, buildBody) { ); }; -exports.ComprehensionExpression = function (node, parent, file) { +exports.ComprehensionExpression = function (node, parent, file, scope) { if (node.generator) return; - return build(node, file); + return build(node, parent, file, scope); }; diff --git a/lib/6to5/transformation/transformers/playground-memoization-operator.js b/lib/6to5/transformation/transformers/playground-memoization-operator.js index 5d6ec25ade..f9411c8d00 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 = file.generateUidIdentifier("propKey", scope); + var temp = t.getUid(prop, file, scope); nodes.push(t.variableDeclaration("var", [ t.variableDeclarator(temp, prop) ])); @@ -20,7 +20,7 @@ var getPropRef = function (nodes, prop, file, scope) { var getObjRef = function (nodes, obj, file, scope) { if (t.isDynamic(obj)) { - var temp = file.generateUidIdentifier("obj", scope); + var temp = t.getUid(obj, file, scope); nodes.push(t.variableDeclaration("var", [ t.variableDeclarator(temp, obj) ])); diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index c5d66ecb1f..53f5f3842e 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -156,7 +156,7 @@ t.toIdentifier = function (name) { if (t.isIdentifier(name)) return name.name; // replace all non-valid identifiers with dashes - name = name.replace(/[^a-zA-Z0-9]/g, "-"); + name = name.replace(/[^a-zA-Z0-9$_]/g, "-"); // remove all dashes and numbers from start of name name = name.replace(/^[-0-9]+/, ""); @@ -166,6 +166,9 @@ t.toIdentifier = function (name) { return c ? c.toUpperCase() : ""; }); + // remove underscores from start of name + name = name.replace(/^\_/, ""); + return name || '_'; }; @@ -231,6 +234,49 @@ t.toBlock = function (node, parent) { return t.blockStatement(node); }; +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); +}; + t.getIds = function (node, map, ignoreTypes) { ignoreTypes = ignoreTypes || []; diff --git a/lib/6to5/util.js b/lib/6to5/util.js index 98f2e6f3b7..033fa3c3bb 100644 --- a/lib/6to5/util.js +++ b/lib/6to5/util.js @@ -52,22 +52,6 @@ exports.arrayify = function (val) { throw new TypeError("illegal type for arrayify"); }; -exports.getUid = function (parent, file) { - var node; - - if (t.isAssignmentExpression(parent)) { - node = parent.left; - } else if (t.isVariableDeclarator(parent)) { - node = parent.id; - } - - var id = "ref"; - - if (t.isIdentifier(node)) id = node.name; - - return file.generateUidIdentifier(id); -}; - exports.isAbsolute = function (loc) { if (!loc) return false; if (loc[0] === "/") return true; // unix 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 66577c1cc1..3de724c2c7 100644 --- a/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js +++ b/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js @@ -14,32 +14,32 @@ var _inherits = function (child, parent) { }; var Test = (function () { - var _TestSuper = Foo; + var _Foo = Foo; var Test = function Test() { woops["super"].test(); - _TestSuper.call(this); - _TestSuper.prototype.test.call(this); - foob(_TestSuper); + _Foo.call(this); + _Foo.prototype.test.call(this); + foob(_Foo); - _TestSuper.call.apply(_TestSuper, [this].concat(_slice.call(arguments))); - _TestSuper.call.apply(_TestSuper, [this, "test"].concat(_slice.call(arguments))); + _Foo.call.apply(_Foo, [this].concat(_slice.call(arguments))); + _Foo.call.apply(_Foo, [this, "test"].concat(_slice.call(arguments))); - _TestSuper.prototype.test.call.apply(_TestSuper.prototype, [this].concat(_slice.call(arguments))); - _TestSuper.prototype.test.call.apply(_TestSuper.prototype, [this, "test"].concat(_slice.call(arguments))); + _Foo.prototype.test.call.apply(_Foo.prototype, [this].concat(_slice.call(arguments))); + _Foo.prototype.test.call.apply(_Foo.prototype, [this, "test"].concat(_slice.call(arguments))); }; - _inherits(Test, _TestSuper); + _inherits(Test, _Foo); Test.prototype.test = function () { - _TestSuper.prototype.test.call(this); - _TestSuper.prototype.test.call.apply(_TestSuper.prototype.test, [this].concat(_slice.call(arguments))); - _TestSuper.prototype.test.call.apply(_TestSuper.prototype.test, [this, "test"].concat(_slice.call(arguments))); + _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))); }; Test.foo = function () { - _TestSuper.foo.call(this); - _TestSuper.foo.call.apply(_TestSuper.foo, [this].concat(_slice.call(arguments))); - _TestSuper.foo.call.apply(_TestSuper.foo, [this, "test"].concat(_slice.call(arguments))); + _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))); }; return Test; diff --git a/test/fixtures/transformation/es6-classes/accessing-super-properties/expected.js b/test/fixtures/transformation/es6-classes/accessing-super-properties/expected.js index 46d9bf1c41..95ba3c53f4 100644 --- a/test/fixtures/transformation/es6-classes/accessing-super-properties/expected.js +++ b/test/fixtures/transformation/es6-classes/accessing-super-properties/expected.js @@ -13,13 +13,13 @@ var _inherits = function (child, parent) { }; var Test = (function () { - var _TestSuper = Foo; + var _Foo = Foo; var Test = function Test() { - _TestSuper.prototype.test; - _TestSuper.prototype.test.whatever; + _Foo.prototype.test; + _Foo.prototype.test.whatever; }; - _inherits(Test, _TestSuper); + _inherits(Test, _Foo); return Test; })(); diff --git a/test/fixtures/transformation/es6-classes/calling-super-properties/expected.js b/test/fixtures/transformation/es6-classes/calling-super-properties/expected.js index 44f086c4b9..1b2b38ce31 100644 --- a/test/fixtures/transformation/es6-classes/calling-super-properties/expected.js +++ b/test/fixtures/transformation/es6-classes/calling-super-properties/expected.js @@ -13,16 +13,16 @@ var _inherits = function (child, parent) { }; var Test = (function () { - var _TestSuper = Foo; + var _Foo = Foo; var Test = function Test() { - _TestSuper.prototype.test.whatever(); - _TestSuper.prototype.test.call(this); + _Foo.prototype.test.whatever(); + _Foo.prototype.test.call(this); }; - _inherits(Test, _TestSuper); + _inherits(Test, _Foo); Test.test = function () { - return _TestSuper.wow.call(this); + return _Foo.wow.call(this); }; return Test; diff --git a/test/fixtures/transformation/es6-classes/constructor/expected.js b/test/fixtures/transformation/es6-classes/constructor/expected.js index c6b5282782..d43c12f6e7 100644 --- a/test/fixtures/transformation/es6-classes/constructor/expected.js +++ b/test/fixtures/transformation/es6-classes/constructor/expected.js @@ -17,12 +17,12 @@ var Test = function Test() { }; var Foo = (function () { - var _FooSuper = Bar; + var _Bar = Bar; var Foo = function Foo() { this.state = "test"; }; - _inherits(Foo, _FooSuper); + _inherits(Foo, _Bar); return Foo; })(); diff --git a/test/fixtures/transformation/es6-classes/super-class-id-member-expression/expected.js b/test/fixtures/transformation/es6-classes/super-class-id-member-expression/expected.js index cc5ebdee6f..3e58ae4cf4 100644 --- a/test/fixtures/transformation/es6-classes/super-class-id-member-expression/expected.js +++ b/test/fixtures/transformation/es6-classes/super-class-id-member-expression/expected.js @@ -13,27 +13,27 @@ var _inherits = function (child, parent) { }; var BaseController = (function () { - var _BaseControllerSuper = Chaplin.Controller; + var _Chaplin$Controller = Chaplin.Controller; var BaseController = function BaseController() { - if (_BaseControllerSuper) { - _BaseControllerSuper.apply(this, arguments); + if (_Chaplin$Controller) { + _Chaplin$Controller.apply(this, arguments); } }; - _inherits(BaseController, _BaseControllerSuper); + _inherits(BaseController, _Chaplin$Controller); return BaseController; })(); var BaseController2 = (function () { - var _BaseController2Super = Chaplin.Controller.Another; + var _Chaplin$Controller$Another = Chaplin.Controller.Another; var BaseController2 = function BaseController2() { - if (_BaseController2Super) { - _BaseController2Super.apply(this, arguments); + if (_Chaplin$Controller$Another) { + _Chaplin$Controller$Another.apply(this, arguments); } }; - _inherits(BaseController2, _BaseController2Super); + _inherits(BaseController2, _Chaplin$Controller$Another); return BaseController2; })(); diff --git a/test/fixtures/transformation/es6-classes/super-class/expected.js b/test/fixtures/transformation/es6-classes/super-class/expected.js index 8e7db71d24..d57ed0b72c 100644 --- a/test/fixtures/transformation/es6-classes/super-class/expected.js +++ b/test/fixtures/transformation/es6-classes/super-class/expected.js @@ -13,14 +13,14 @@ var _inherits = function (child, parent) { }; var Test = (function () { - var _TestSuper = Foo; + var _Foo = Foo; var Test = function Test() { - if (_TestSuper) { - _TestSuper.apply(this, arguments); + if (_Foo) { + _Foo.apply(this, arguments); } }; - _inherits(Test, _TestSuper); + _inherits(Test, _Foo); return Test; })(); diff --git a/test/fixtures/transformation/es6-constants/destructuring/expected.js b/test/fixtures/transformation/es6-constants/destructuring/expected.js index 66a0ec1aa4..98550a79f2 100644 --- a/test/fixtures/transformation/es6-constants/destructuring/expected.js +++ b/test/fixtures/transformation/es6-constants/destructuring/expected.js @@ -24,15 +24,15 @@ var a = _ref2[0]; var b = _ref2[1]; var _ref3 = [3, 4]; -var _ref4 = _slicedToArray(_ref3, 2); +var _ref3 = _slicedToArray(_ref3, 2); -var c = _ref4[0]; -var d = _ref4[1]; -var _ref5 = { e: 5, f: 6 }; +var c = _ref3[0]; +var d = _ref3[1]; +var _ref4 = { e: 5, f: 6 }; -var e = _ref5.e; -var f = _ref5.f; -var _ref6 = { a: 7, b: 8 }; +var e = _ref4.e; +var f = _ref4.f; +var _ref5 = { a: 7, b: 8 }; -var g = _ref6.a; -var h = _ref6.b; +var g = _ref5.a; +var h = _ref5.b; diff --git a/test/fixtures/transformation/es6-destructuring/array/expected.js b/test/fixtures/transformation/es6-destructuring/array/expected.js index 9fb14067aa..8f3e9ae760 100644 --- a/test/fixtures/transformation/es6-destructuring/array/expected.js +++ b/test/fixtures/transformation/es6-destructuring/array/expected.js @@ -21,10 +21,10 @@ var _ref = ["hello", [", ", "junk"], ["world"]]; var _ref2 = _slicedToArray(_ref, 4); var a = _ref2[0]; -var _ref3 = _slicedToArray(_ref2[1], 1); +var _ref2$1 = _slicedToArray(_ref2[1], 1); -var b = _ref3[0]; -var _ref4 = _slicedToArray(_ref2[2], 1); +var b = _ref2$1[0]; +var _ref2$2 = _slicedToArray(_ref2[2], 1); -var c = _ref4[0]; +var c = _ref2$2[0]; var d = _ref2[3]; diff --git a/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js b/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js index af2b8a0984..d626efc045 100644 --- a/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js +++ b/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _temp, _ref; +var _temp, _temp2; var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; @@ -17,4 +17,4 @@ var _slicedToArray = function (arr, i) { } }; -console.log((_temp = [123], _ref = _slicedToArray(_temp, 1), x = _ref[0], _temp)); +console.log((_temp = [123], _temp2 = _slicedToArray(_temp, 1), x = _temp2[0], _temp)); diff --git a/test/fixtures/transformation/es6-destructuring/empty/expected.js b/test/fixtures/transformation/es6-destructuring/empty/expected.js index 03bf0aa988..e9ab526e46 100644 --- a/test/fixtures/transformation/es6-destructuring/empty/expected.js +++ b/test/fixtures/transformation/es6-destructuring/empty/expected.js @@ -21,10 +21,10 @@ var _ref = ["foo", "hello", [", ", "junk"], ["world"]]; var _ref2 = _slicedToArray(_ref, 5); var a = _ref2[1]; -var _ref3 = _slicedToArray(_ref2[2], 1); +var _ref2$2 = _slicedToArray(_ref2[2], 1); -var b = _ref3[0]; -var _ref4 = _slicedToArray(_ref2[3], 1); +var b = _ref2$2[0]; +var _ref2$3 = _slicedToArray(_ref2[3], 1); -var c = _ref4[0]; +var c = _ref2$3[0]; var d = _ref2[4]; diff --git a/test/fixtures/transformation/es6-destructuring/mixed/expected.js b/test/fixtures/transformation/es6-destructuring/mixed/expected.js index 2fac921701..9464df1648 100644 --- a/test/fixtures/transformation/es6-destructuring/mixed/expected.js +++ b/test/fixtures/transformation/es6-destructuring/mixed/expected.js @@ -16,11 +16,11 @@ var _slicedToArray = function (arr, i) { } }; -var _ref = _slicedToArray(rect.topLeft, 2); +var _rect$topLeft = _slicedToArray(rect.topLeft, 2); -var x1 = _ref[0]; -var y1 = _ref[1]; -var _ref2 = _slicedToArray(rect.bottomRight, 2); +var x1 = _rect$topLeft[0]; +var y1 = _rect$topLeft[1]; +var _rect$bottomRight = _slicedToArray(rect.bottomRight, 2); -var x2 = _ref2[0]; -var y2 = _ref2[1]; +var x2 = _rect$bottomRight[0]; +var y2 = _rect$bottomRight[1]; diff --git a/test/fixtures/transformation/es6-destructuring/parameters/expected.js b/test/fixtures/transformation/es6-destructuring/parameters/expected.js index a378836955..a6a1d3dfe6 100644 --- a/test/fixtures/transformation/es6-destructuring/parameters/expected.js +++ b/test/fixtures/transformation/es6-destructuring/parameters/expected.js @@ -31,17 +31,17 @@ function unpackObject(_ref2) { console.log(unpackObject({ title: "title", author: "author" })); -var unpackArray = function (_ref3, _ref5) { - var _ref4 = _slicedToArray(_ref3, 3); +var unpackArray = function (_ref3, _ref4) { + var _ref3 = _slicedToArray(_ref3, 3); - var a = _ref4[0]; - var b = _ref4[1]; - var c = _ref4[2]; - var _ref6 = _slicedToArray(_ref5, 3); + var a = _ref3[0]; + var b = _ref3[1]; + var c = _ref3[2]; + var _ref4 = _slicedToArray(_ref4, 3); - var x = _ref6[0]; - var y = _ref6[1]; - var z = _ref6[2]; + var x = _ref4[0]; + var y = _ref4[1]; + var z = _ref4[2]; return a + b + c; }; diff --git a/test/fixtures/transformation/es7-array-comprehension/arguments/expected.js b/test/fixtures/transformation/es7-array-comprehension/arguments/expected.js index fc982c26c9..39115d87d3 100644 --- a/test/fixtures/transformation/es7-array-comprehension/arguments/expected.js +++ b/test/fixtures/transformation/es7-array-comprehension/arguments/expected.js @@ -3,14 +3,14 @@ function add() { var _arguments = arguments; return (function () { - var _arr = []; + var _ref = []; for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var i = _step.value; - _arr.push(i * _arguments[0]); + _ref.push(i * _arguments[0]); } - return _arr; + return _ref; })(); } diff --git a/test/fixtures/transformation/es7-array-comprehension/multiple-if/expected.js b/test/fixtures/transformation/es7-array-comprehension/multiple-if/expected.js index d5695f85cb..6b486b45f5 100644 --- a/test/fixtures/transformation/es7-array-comprehension/multiple-if/expected.js +++ b/test/fixtures/transformation/es7-array-comprehension/multiple-if/expected.js @@ -1,17 +1,17 @@ "use strict"; var seattlers = (function () { - var _arr = []; + var _seattlers = []; for (var _iterator = countries[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var customers = _step.value; for (var _iterator2 = customers[Symbol.iterator](), _step2; !(_step2 = _iterator2.next()).done;) { var c = _step2.value; if (c.city == "Seattle") { - _arr.push({ name: c.name, age: c.age }); + _seattlers.push({ name: c.name, age: c.age }); } } } - return _arr; + return _seattlers; })(); diff --git a/test/fixtures/transformation/es7-array-comprehension/this/expected.js b/test/fixtures/transformation/es7-array-comprehension/this/expected.js index c91ca8a560..5645b53dcc 100644 --- a/test/fixtures/transformation/es7-array-comprehension/this/expected.js +++ b/test/fixtures/transformation/es7-array-comprehension/this/expected.js @@ -3,14 +3,14 @@ function add() { var _this = this; return (function () { - var _arr = []; + var _ref = []; for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var i = _step.value; - _arr.push(i * _this.multiplier); + _ref.push(i * _this.multiplier); } - return _arr; + return _ref; })(); } diff --git a/test/fixtures/transformation/optional-core-aliasing/es6-destructuring/expected.js b/test/fixtures/transformation/optional-core-aliasing/es6-destructuring/expected.js index 2a92073140..e8d65b8085 100644 --- a/test/fixtures/transformation/optional-core-aliasing/es6-destructuring/expected.js +++ b/test/fixtures/transformation/optional-core-aliasing/es6-destructuring/expected.js @@ -27,10 +27,10 @@ var _ref = ["hello", [", ", "junk"], ["world"]]; var _ref2 = _slicedToArray(_ref, 4); var a = _ref2[0]; -var _ref3 = _slicedToArray(_ref2[1], 1); +var _ref2$1 = _slicedToArray(_ref2[1], 1); -var b = _ref3[0]; -var _ref4 = _slicedToArray(_ref2[2], 1); +var b = _ref2$1[0]; +var _ref2$2 = _slicedToArray(_ref2[2], 1); -var c = _ref4[0]; +var c = _ref2$2[0]; var d = _ref2[3]; diff --git a/test/fixtures/transformation/playground/memoization-assignment-operator/expected.js b/test/fixtures/transformation/playground/memoization-assignment-operator/expected.js index e00aea8c5e..de72bd3e59 100644 --- a/test/fixtures/transformation/playground/memoization-assignment-operator/expected.js +++ b/test/fixtures/transformation/playground/memoization-assignment-operator/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _propKey2, _obj2, _propKey4; +var _ref2, _obj2, _ref4; var _hasOwn = Object.prototype.hasOwnProperty; var obj = {}; @@ -9,17 +9,17 @@ if (!_hasOwn.call(obj, "x")) obj.x = 2; console.log((!_hasOwn.call(obj, "x") && (obj.x = 2), obj.x)); -var _propKey = x(); +var _ref = x(); -if (!_hasOwn.call(obj, _propKey)) obj[_propKey] = 2; +if (!_hasOwn.call(obj, _ref)) obj[_ref] = 2; -console.log((_propKey2 = x(), !_hasOwn.call(obj, _propKey2) && (obj[_propKey2] = 2), obj[_propKey2])); +console.log((_ref2 = x(), !_hasOwn.call(obj, _ref2) && (obj[_ref2] = 2), obj[_ref2])); var _obj = obj[y()]; -var _propKey3 = x(); +var _ref3 = x(); -if (!_hasOwn.call(_obj, _propKey3)) _obj[_propKey3] = 2; +if (!_hasOwn.call(_obj, _ref3)) _obj[_ref3] = 2; -console.log((_obj2 = obj[y()], _propKey4 = x(), !_hasOwn.call(_obj2, _propKey4) && (_obj2[_propKey4] = 2), _obj2[_propKey4])); +console.log((_obj2 = obj[y()], _ref4 = x(), !_hasOwn.call(_obj2, _ref4) && (_obj2[_ref4] = 2), _obj2[_ref4]));