diff --git a/CHANGELOG.md b/CHANGELOG.md index ce20a6713b..e6a97d685e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,9 @@ Gaps between patch versions are faulty/broken releases. * Freeze tagged template literal object. * Remove inlined `regenerator` fork. * Remove `ParenthesizedExpression`. + * Rename `object-spread` helper to `object-without-properties`. + * Rename `class-props` helper to `prototype-properties`. + * Rename `extends` helper to `inherits`. ## 1.15.0 diff --git a/lib/6to5/file.js b/lib/6to5/file.js index b4a926745d..35230e9aa6 100644 --- a/lib/6to5/file.js +++ b/lib/6to5/file.js @@ -17,13 +17,13 @@ function File(opts) { } File.declarations = [ - "extends", - "class-props", + "inherits", + "prototype-properties", "apply-constructor", "tagged-template-literal", "interop-require", "to-array", - "object-spread", + "object-without-properties", "has-own", "slice" ]; diff --git a/lib/6to5/templates/extends.js b/lib/6to5/templates/inherits.js similarity index 100% rename from lib/6to5/templates/extends.js rename to lib/6to5/templates/inherits.js diff --git a/lib/6to5/templates/object-spread.js b/lib/6to5/templates/object-without-properties.js similarity index 100% rename from lib/6to5/templates/object-spread.js rename to lib/6to5/templates/object-without-properties.js diff --git a/lib/6to5/templates/class-props.js b/lib/6to5/templates/prototype-properties.js similarity index 100% rename from lib/6to5/templates/class-props.js rename to lib/6to5/templates/prototype-properties.js diff --git a/lib/6to5/transformation/transformers/es6-classes.js b/lib/6to5/transformation/transformers/es6-classes.js index f43f522f60..71e3e2680a 100644 --- a/lib/6to5/transformation/transformers/es6-classes.js +++ b/lib/6to5/transformation/transformers/es6-classes.js @@ -77,7 +77,7 @@ Class.prototype.run = function () { // if (superName) { - body.push(t.expressionStatement(t.callExpression(file.addDeclaration("extends"), [className, superName]))); + body.push(t.expressionStatement(t.callExpression(file.addDeclaration("inherits"), [className, superName]))); } this.buildBody(); @@ -156,7 +156,7 @@ Class.prototype.buildBody = function () { if (instanceProps) args.push(instanceProps); body.push(t.expressionStatement( - t.callExpression(this.file.addDeclaration("class-props"), args) + t.callExpression(this.file.addDeclaration("prototype-properties"), args) )); } }; diff --git a/lib/6to5/transformation/transformers/es6-destructuring.js b/lib/6to5/transformation/transformers/es6-destructuring.js index 3e7db9894a..7353760ea0 100644 --- a/lib/6to5/transformation/transformers/es6-destructuring.js +++ b/lib/6to5/transformation/transformers/es6-destructuring.js @@ -45,7 +45,7 @@ var pushObjectPattern = function (opts, nodes, pattern, parentId) { } keys = t.arrayExpression(keys); - var value = t.callExpression(opts.file.addDeclaration("object-spread"), [parentId, keys]); + var value = t.callExpression(opts.file.addDeclaration("object-without-properties"), [parentId, keys]); nodes.push(buildVariableAssign(opts, prop.argument, value)); } else { var pattern2 = prop.value; 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 14523f5053..fd7527b70a 100644 --- a/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js +++ b/test/fixtures/transformation/es6-classes/accessing-super-class/expected.js @@ -1,7 +1,7 @@ "use strict"; var _slice = Array.prototype.slice; -var _extends = function (child, parent) { +var _inherits = function (child, parent) { child.prototype = Object.create(parent && parent.prototype, { constructor: { value: child, @@ -26,7 +26,7 @@ var Test = function Test() { Foo.prototype.test.call.apply(Foo.prototype, [this, "test"].concat(_slice.call(arguments))); }; -_extends(Test, Foo); +_inherits(Test, Foo); Test.prototype.test = function () { Foo.prototype.test.call(this); 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 b04502c5e3..64df221c08 100644 --- a/test/fixtures/transformation/es6-classes/accessing-super-properties/expected.js +++ b/test/fixtures/transformation/es6-classes/accessing-super-properties/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _extends = function (child, parent) { +var _inherits = function (child, parent) { child.prototype = Object.create(parent && parent.prototype, { constructor: { value: child, @@ -17,4 +17,4 @@ var Test = function Test() { Foo.prototype.test.whatever; }; -_extends(Test, Foo); +_inherits(Test, Foo); 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 424555b3f4..d13ee876cd 100644 --- a/test/fixtures/transformation/es6-classes/calling-super-properties/expected.js +++ b/test/fixtures/transformation/es6-classes/calling-super-properties/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _extends = function (child, parent) { +var _inherits = function (child, parent) { child.prototype = Object.create(parent && parent.prototype, { constructor: { value: child, @@ -17,7 +17,7 @@ var Test = function Test() { Foo.prototype.test.call(this); }; -_extends(Test, Foo); +_inherits(Test, Foo); Test.test = function () { return Foo.wow.call(this); diff --git a/test/fixtures/transformation/es6-classes/constructor/expected.js b/test/fixtures/transformation/es6-classes/constructor/expected.js index 5771cc0767..00e97931b5 100644 --- a/test/fixtures/transformation/es6-classes/constructor/expected.js +++ b/test/fixtures/transformation/es6-classes/constructor/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _extends = function (child, parent) { +var _inherits = function (child, parent) { child.prototype = Object.create(parent && parent.prototype, { constructor: { value: child, @@ -20,4 +20,4 @@ var Foo = function Foo() { this.state = "test"; }; -_extends(Foo, Bar); +_inherits(Foo, Bar); diff --git a/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js b/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js index fed43faa63..391423e078 100644 --- a/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js @@ -1,13 +1,13 @@ "use strict"; -var _classProps = function (child, staticProps, instanceProps) { +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; var Test = function Test() {}; -_classProps(Test, null, { +_prototypeProperties(Test, null, { test: { get: function () { return 5 + 5; diff --git a/test/fixtures/transformation/es6-classes/instance-getter/expected.js b/test/fixtures/transformation/es6-classes/instance-getter/expected.js index 4b52e5a6e2..6fa5d59400 100644 --- a/test/fixtures/transformation/es6-classes/instance-getter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-getter/expected.js @@ -1,13 +1,13 @@ "use strict"; -var _classProps = function (child, staticProps, instanceProps) { +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; var Test = function Test() {}; -_classProps(Test, null, { +_prototypeProperties(Test, null, { test: { get: function () { return 5 + 5; diff --git a/test/fixtures/transformation/es6-classes/instance-setter/expected.js b/test/fixtures/transformation/es6-classes/instance-setter/expected.js index 0f47c5db71..2ffe02b551 100644 --- a/test/fixtures/transformation/es6-classes/instance-setter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-setter/expected.js @@ -1,13 +1,13 @@ "use strict"; -var _classProps = function (child, staticProps, instanceProps) { +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; var Test = function Test() {}; -_classProps(Test, null, { +_prototypeProperties(Test, null, { test: { set: function (val) { this._test = val; diff --git a/test/fixtures/transformation/es6-classes/static/expected.js b/test/fixtures/transformation/es6-classes/static/expected.js index 5898b4e35d..e7d7df4451 100644 --- a/test/fixtures/transformation/es6-classes/static/expected.js +++ b/test/fixtures/transformation/es6-classes/static/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _classProps = function (child, staticProps, instanceProps) { +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; @@ -9,7 +9,7 @@ var A = function A() {}; A.a = function () {}; -_classProps(A, { +_prototypeProperties(A, { b: { get: function () {}, set: function (b) {}, 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 8349f0dbe3..70de0712ea 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 @@ -1,6 +1,6 @@ "use strict"; -var _extends = function (child, parent) { +var _inherits = function (child, parent) { child.prototype = Object.create(parent && parent.prototype, { constructor: { value: child, @@ -18,7 +18,7 @@ var BaseController = function BaseController() { } }; -_extends(BaseController, Chaplin.Controller); +_inherits(BaseController, Chaplin.Controller); var BaseController2 = function BaseController2() { if (Chaplin.Controller.Another) { @@ -26,4 +26,4 @@ var BaseController2 = function BaseController2() { } }; -_extends(BaseController2, Chaplin.Controller.Another); +_inherits(BaseController2, Chaplin.Controller.Another); diff --git a/test/fixtures/transformation/es6-classes/super-class-id-non-identifiers/expected.js b/test/fixtures/transformation/es6-classes/super-class-id-non-identifiers/expected.js index e3085e2526..15f2fd75c4 100644 --- a/test/fixtures/transformation/es6-classes/super-class-id-non-identifiers/expected.js +++ b/test/fixtures/transformation/es6-classes/super-class-id-non-identifiers/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _extends = function (child, parent) { +var _inherits = function (child, parent) { child.prototype = Object.create(parent && parent.prototype, { constructor: { value: child, @@ -20,4 +20,4 @@ var Q = function Q() { } }; -_extends(Q, _QSuper); +_inherits(Q, _QSuper); diff --git a/test/fixtures/transformation/es6-classes/super-class/expected.js b/test/fixtures/transformation/es6-classes/super-class/expected.js index d7d6bcbb27..d7a906d848 100644 --- a/test/fixtures/transformation/es6-classes/super-class/expected.js +++ b/test/fixtures/transformation/es6-classes/super-class/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _extends = function (child, parent) { +var _inherits = function (child, parent) { child.prototype = Object.create(parent && parent.prototype, { constructor: { value: child, @@ -18,4 +18,4 @@ var Test = function Test() { } }; -_extends(Test, Foo); +_inherits(Test, Foo); diff --git a/test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js b/test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js index 50857a50a3..8a6ade7f6f 100644 --- a/test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js +++ b/test/fixtures/transformation/es6-destructuring/es7-object-rest/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _objectSpread = function (obj, keys) { +var _objectWithoutProperties = function (obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; @@ -11,12 +11,12 @@ var _objectSpread = function (obj, keys) { return target; }; -var x = _objectSpread(z, []); +var x = _objectWithoutProperties(z, []); var x = z.x; -var y = _objectSpread(z, ["x"]); +var y = _objectWithoutProperties(z, ["x"]); (function (_ref) { var x = _ref.x; - var y = _objectSpread(_ref, ["x"]); + var y = _objectWithoutProperties(_ref, ["x"]); }); diff --git a/test/fixtures/transformation/playground/object-getter-memoization/expected.js b/test/fixtures/transformation/playground/object-getter-memoization/expected.js index 68a1265fd0..bc4288930a 100644 --- a/test/fixtures/transformation/playground/object-getter-memoization/expected.js +++ b/test/fixtures/transformation/playground/object-getter-memoization/expected.js @@ -1,13 +1,13 @@ "use strict"; -var _classProps = function (child, staticProps, instanceProps) { +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; var Foo = function Foo() {}; -_classProps(Foo, null, (function (_ref) { +_prototypeProperties(Foo, null, (function (_ref) { _ref[bar] = { get: function () { if (this._memoDone) return this._memo; diff --git a/test/fixtures/transformation/source-maps/class/expected.js b/test/fixtures/transformation/source-maps/class/expected.js index 8d4a322398..af92fdbd5c 100644 --- a/test/fixtures/transformation/source-maps/class/expected.js +++ b/test/fixtures/transformation/source-maps/class/expected.js @@ -1,13 +1,13 @@ "use strict"; -var _classProps = function (child, staticProps, instanceProps) { +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; var Test = function Test() {}; -_classProps(Test, null, { +_prototypeProperties(Test, null, { bar: { get: function () { throw new Error("wow");