From 19b1032474bb8d9d1b7f84a286bdf87bc5c3a514 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 10 Jul 2015 19:34:32 -0700 Subject: [PATCH] Hoist class inheritance call so it runs before prototype use - fixes #1972 --- .../transformers/es6/classes/vanilla.js | 4 +++- .../accessing-super-class/expected.js | 4 ++-- .../accessing-super-properties/expected.js | 5 +++-- .../calling-super-properties/expected.js | 6 +++--- .../es6.classes-loose/method-order/actual.js | 11 ++++++++++ .../method-order/expected.js | 21 +++++++++++++++++++ .../expected.js | 6 ++++-- .../es6.classes-loose/super-class/expected.js | 3 ++- .../accessing-super-class/expected.js | 5 +++-- .../accessing-super-properties/expected.js | 5 +++-- .../calling-super-properties/expected.js | 3 ++- .../es6.classes/constructor/expected.js | 3 ++- .../expected.js | 3 ++- .../expected.js | 5 +++-- .../super-class-anonymous/expected.js | 17 +++++++++------ .../expected.js | 8 ++++--- .../es6.classes/super-class/expected.js | 5 +++-- .../rest-nested-iife/expected.js | 4 ++-- .../es7.class-properties/derived/expected.js | 5 +++-- .../super-expression/expected.js | 5 +++-- .../super-statement/expected.js | 5 +++-- .../es7.decorators/class-super/expected.js | 8 ++++--- .../misc/regression-1155/expected.js | 3 ++- .../expected.js | 5 +++-- .../spec.function-name/modules-3/expected.js | 5 +++-- .../spec.proto-to-assign/class/expected.js | 5 +++-- 26 files changed, 110 insertions(+), 49 deletions(-) create mode 100644 test/core/fixtures/transformation/es6.classes-loose/method-order/actual.js create mode 100644 test/core/fixtures/transformation/es6.classes-loose/method-order/expected.js diff --git a/src/babel/transformation/transformers/es6/classes/vanilla.js b/src/babel/transformation/transformers/es6/classes/vanilla.js index db0845a05f..b4fe2675ed 100644 --- a/src/babel/transformation/transformers/es6/classes/vanilla.js +++ b/src/babel/transformation/transformers/es6/classes/vanilla.js @@ -592,8 +592,10 @@ export default class ClassTransformer { pushInherits() { if (!this.isDerived || this.pushedInherits) return; + // Unshift to ensure that the constructor inheritance is set up before + // any properties can be assigned to the prototype. this.pushedInherits = true; - this.body.push(t.expressionStatement(t.callExpression( + this.body.unshift(t.expressionStatement(t.callExpression( this.file.addHelper("inherits"), [this.classRef, this.superName] ))); diff --git a/test/core/fixtures/transformation/es6.classes-loose/accessing-super-class/expected.js b/test/core/fixtures/transformation/es6.classes-loose/accessing-super-class/expected.js index 0001aaf002..f46e74a4b1 100644 --- a/test/core/fixtures/transformation/es6.classes-loose/accessing-super-class/expected.js +++ b/test/core/fixtures/transformation/es6.classes-loose/accessing-super-class/expected.js @@ -1,6 +1,8 @@ "use strict"; var Test = (function (_Foo) { + babelHelpers.inherits(Test, _Foo); + function Test() { var _Foo$prototype$test, _Foo$prototype$test2; @@ -17,8 +19,6 @@ var Test = (function (_Foo) { (_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(babelHelpers.slice.call(arguments))); } - babelHelpers.inherits(Test, _Foo); - Test.prototype.test = function test() { var _Foo$prototype$test3, _Foo$prototype$test4; diff --git a/test/core/fixtures/transformation/es6.classes-loose/accessing-super-properties/expected.js b/test/core/fixtures/transformation/es6.classes-loose/accessing-super-properties/expected.js index 009804c65e..d35e8b20ae 100644 --- a/test/core/fixtures/transformation/es6.classes-loose/accessing-super-properties/expected.js +++ b/test/core/fixtures/transformation/es6.classes-loose/accessing-super-properties/expected.js @@ -1,6 +1,8 @@ "use strict"; var Test = (function (_Foo) { + babelHelpers.inherits(Test, _Foo); + function Test() { babelHelpers.classCallCheck(this, Test); @@ -9,6 +11,5 @@ var Test = (function (_Foo) { _Foo.prototype.test.whatever; } - babelHelpers.inherits(Test, _Foo); return Test; -})(Foo); \ No newline at end of file +})(Foo); diff --git a/test/core/fixtures/transformation/es6.classes-loose/calling-super-properties/expected.js b/test/core/fixtures/transformation/es6.classes-loose/calling-super-properties/expected.js index ad9b87b712..522bd45ff1 100644 --- a/test/core/fixtures/transformation/es6.classes-loose/calling-super-properties/expected.js +++ b/test/core/fixtures/transformation/es6.classes-loose/calling-super-properties/expected.js @@ -1,6 +1,8 @@ "use strict"; var Test = (function (_Foo) { + babelHelpers.inherits(Test, _Foo); + function Test() { babelHelpers.classCallCheck(this, Test); @@ -9,11 +11,9 @@ var Test = (function (_Foo) { _Foo.prototype.test.call(this); } - babelHelpers.inherits(Test, _Foo); - Test.test = function test() { return _Foo.wow.call(this); }; return Test; -})(Foo); \ No newline at end of file +})(Foo); diff --git a/test/core/fixtures/transformation/es6.classes-loose/method-order/actual.js b/test/core/fixtures/transformation/es6.classes-loose/method-order/actual.js new file mode 100644 index 0000000000..1cbc01438c --- /dev/null +++ b/test/core/fixtures/transformation/es6.classes-loose/method-order/actual.js @@ -0,0 +1,11 @@ +class Foo {} + +class Bar extends Foo { + methodA(){} + + constructor(){ + super(); + } + + methodB(){} +} diff --git a/test/core/fixtures/transformation/es6.classes-loose/method-order/expected.js b/test/core/fixtures/transformation/es6.classes-loose/method-order/expected.js new file mode 100644 index 0000000000..f7cd7a462c --- /dev/null +++ b/test/core/fixtures/transformation/es6.classes-loose/method-order/expected.js @@ -0,0 +1,21 @@ +"use strict"; + +var Foo = function Foo() { + babelHelpers.classCallCheck(this, Foo); +}; + +var Bar = (function (_Foo) { + babelHelpers.inherits(Bar, _Foo); + + Bar.prototype.methodA = function methodA() {}; + + function Bar() { + babelHelpers.classCallCheck(this, Bar); + + _Foo.call(this); + } + + Bar.prototype.methodB = function methodB() {}; + + return Bar; +})(Foo); diff --git a/test/core/fixtures/transformation/es6.classes-loose/super-class-id-member-expression/expected.js b/test/core/fixtures/transformation/es6.classes-loose/super-class-id-member-expression/expected.js index 14f00f622a..ab9eedf6df 100644 --- a/test/core/fixtures/transformation/es6.classes-loose/super-class-id-member-expression/expected.js +++ b/test/core/fixtures/transformation/es6.classes-loose/super-class-id-member-expression/expected.js @@ -1,23 +1,25 @@ "use strict"; var BaseController = (function (_Chaplin$Controller) { + babelHelpers.inherits(BaseController, _Chaplin$Controller); + function BaseController() { babelHelpers.classCallCheck(this, BaseController); _Chaplin$Controller.apply(this, arguments); } - babelHelpers.inherits(BaseController, _Chaplin$Controller); return BaseController; })(Chaplin.Controller); var BaseController2 = (function (_Chaplin$Controller$Another) { + babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another); + function BaseController2() { babelHelpers.classCallCheck(this, BaseController2); _Chaplin$Controller$Another.apply(this, arguments); } - babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another); return BaseController2; })(Chaplin.Controller.Another); diff --git a/test/core/fixtures/transformation/es6.classes-loose/super-class/expected.js b/test/core/fixtures/transformation/es6.classes-loose/super-class/expected.js index 161d930afe..a1b0761440 100644 --- a/test/core/fixtures/transformation/es6.classes-loose/super-class/expected.js +++ b/test/core/fixtures/transformation/es6.classes-loose/super-class/expected.js @@ -1,12 +1,13 @@ "use strict"; var Test = (function (_Foo) { + babelHelpers.inherits(Test, _Foo); + function Test() { babelHelpers.classCallCheck(this, Test); _Foo.apply(this, arguments); } - babelHelpers.inherits(Test, _Foo); return Test; })(Foo); diff --git a/test/core/fixtures/transformation/es6.classes/accessing-super-class/expected.js b/test/core/fixtures/transformation/es6.classes/accessing-super-class/expected.js index 42672ea451..80e467ff26 100644 --- a/test/core/fixtures/transformation/es6.classes/accessing-super-class/expected.js +++ b/test/core/fixtures/transformation/es6.classes/accessing-super-class/expected.js @@ -1,6 +1,8 @@ "use strict"; var Test = (function (_Foo) { + babelHelpers.inherits(Test, _Foo); + function Test() { var _babelHelpers$get, _babelHelpers$get2; @@ -17,7 +19,6 @@ var Test = (function (_Foo) { (_babelHelpers$get2 = babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get2, [this, "test"].concat(babelHelpers.slice.call(arguments))); } - babelHelpers.inherits(Test, _Foo); babelHelpers.createClass(Test, [{ key: "test", value: function test() { @@ -38,4 +39,4 @@ var Test = (function (_Foo) { } }]); return Test; -})(Foo); \ No newline at end of file +})(Foo); diff --git a/test/core/fixtures/transformation/es6.classes/accessing-super-properties/expected.js b/test/core/fixtures/transformation/es6.classes/accessing-super-properties/expected.js index 9ab2af0f38..5eb06810f8 100644 --- a/test/core/fixtures/transformation/es6.classes/accessing-super-properties/expected.js +++ b/test/core/fixtures/transformation/es6.classes/accessing-super-properties/expected.js @@ -1,6 +1,8 @@ "use strict"; var Test = (function (_Foo) { + babelHelpers.inherits(Test, _Foo); + function Test() { babelHelpers.classCallCheck(this, Test); @@ -9,6 +11,5 @@ var Test = (function (_Foo) { babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).whatever; } - babelHelpers.inherits(Test, _Foo); return Test; -})(Foo); \ No newline at end of file +})(Foo); diff --git a/test/core/fixtures/transformation/es6.classes/calling-super-properties/expected.js b/test/core/fixtures/transformation/es6.classes/calling-super-properties/expected.js index bd6aedcc2a..2171f302f5 100644 --- a/test/core/fixtures/transformation/es6.classes/calling-super-properties/expected.js +++ b/test/core/fixtures/transformation/es6.classes/calling-super-properties/expected.js @@ -1,6 +1,8 @@ "use strict"; var Test = (function (_Foo) { + babelHelpers.inherits(Test, _Foo); + function Test() { babelHelpers.classCallCheck(this, Test); @@ -9,7 +11,6 @@ var Test = (function (_Foo) { babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).call(this); } - babelHelpers.inherits(Test, _Foo); babelHelpers.createClass(Test, null, [{ key: "test", value: function test() { diff --git a/test/core/fixtures/transformation/es6.classes/constructor/expected.js b/test/core/fixtures/transformation/es6.classes/constructor/expected.js index 9aefa96a1c..5fa33a7d94 100644 --- a/test/core/fixtures/transformation/es6.classes/constructor/expected.js +++ b/test/core/fixtures/transformation/es6.classes/constructor/expected.js @@ -7,6 +7,8 @@ var Test = function Test() { }; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo() { babelHelpers.classCallCheck(this, Foo); @@ -14,7 +16,6 @@ var Foo = (function (_Bar) { this.state = "test"; } - babelHelpers.inherits(Foo, _Bar); return Foo; })(Bar); diff --git a/test/core/fixtures/transformation/es6.classes/delay-arrow-function-for-bare-super-derived/expected.js b/test/core/fixtures/transformation/es6.classes/delay-arrow-function-for-bare-super-derived/expected.js index 4140da0602..93be66feef 100644 --- a/test/core/fixtures/transformation/es6.classes/delay-arrow-function-for-bare-super-derived/expected.js +++ b/test/core/fixtures/transformation/es6.classes/delay-arrow-function-for-bare-super-derived/expected.js @@ -1,6 +1,8 @@ "use strict"; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo() { babelHelpers.classCallCheck(this, Foo); @@ -11,6 +13,5 @@ var Foo = (function (_Bar) { var _this = this; } - babelHelpers.inherits(Foo, _Bar); return Foo; })(Bar); diff --git a/test/core/fixtures/transformation/es6.classes/derived-constructor-must-call-super/expected.js b/test/core/fixtures/transformation/es6.classes/derived-constructor-must-call-super/expected.js index af80e3bb86..b62f83e720 100644 --- a/test/core/fixtures/transformation/es6.classes/derived-constructor-must-call-super/expected.js +++ b/test/core/fixtures/transformation/es6.classes/derived-constructor-must-call-super/expected.js @@ -1,10 +1,11 @@ "use strict"; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo() { babelHelpers.classCallCheck(this, Foo); } - babelHelpers.inherits(Foo, _Bar); return Foo; -})(Bar); \ No newline at end of file +})(Bar); diff --git a/test/core/fixtures/transformation/es6.classes/super-class-anonymous/expected.js b/test/core/fixtures/transformation/es6.classes/super-class-anonymous/expected.js index cc74cfb896..7942481077 100644 --- a/test/core/fixtures/transformation/es6.classes/super-class-anonymous/expected.js +++ b/test/core/fixtures/transformation/es6.classes/super-class-anonymous/expected.js @@ -1,12 +1,13 @@ "use strict"; var TestEmpty = (function (_ref) { + babelHelpers.inherits(TestEmpty, _ref); + function TestEmpty() { babelHelpers.classCallCheck(this, TestEmpty); babelHelpers.get(Object.getPrototypeOf(TestEmpty.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(TestEmpty, _ref); return TestEmpty; })((function () { function _class() { @@ -17,12 +18,13 @@ var TestEmpty = (function (_ref) { })()); var TestConstructorOnly = (function (_ref2) { + babelHelpers.inherits(TestConstructorOnly, _ref2); + function TestConstructorOnly() { babelHelpers.classCallCheck(this, TestConstructorOnly); babelHelpers.get(Object.getPrototypeOf(TestConstructorOnly.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(TestConstructorOnly, _ref2); return TestConstructorOnly; })((function () { function _class2() { @@ -33,12 +35,13 @@ var TestConstructorOnly = (function (_ref2) { })()); var TestMethodOnly = (function (_ref3) { + babelHelpers.inherits(TestMethodOnly, _ref3); + function TestMethodOnly() { babelHelpers.classCallCheck(this, TestMethodOnly); babelHelpers.get(Object.getPrototypeOf(TestMethodOnly.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(TestMethodOnly, _ref3); return TestMethodOnly; })((function () { function _class3() { @@ -53,12 +56,13 @@ var TestMethodOnly = (function (_ref3) { })()); var TestConstructorAndMethod = (function (_ref4) { + babelHelpers.inherits(TestConstructorAndMethod, _ref4); + function TestConstructorAndMethod() { babelHelpers.classCallCheck(this, TestConstructorAndMethod); babelHelpers.get(Object.getPrototypeOf(TestConstructorAndMethod.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(TestConstructorAndMethod, _ref4); return TestConstructorAndMethod; })((function () { function _class4() { @@ -73,12 +77,13 @@ var TestConstructorAndMethod = (function (_ref4) { })()); var TestMultipleMethods = (function (_ref5) { + babelHelpers.inherits(TestMultipleMethods, _ref5); + function TestMultipleMethods() { babelHelpers.classCallCheck(this, TestMultipleMethods); babelHelpers.get(Object.getPrototypeOf(TestMultipleMethods.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(TestMultipleMethods, _ref5); return TestMultipleMethods; })((function () { function _class5() { @@ -93,4 +98,4 @@ var TestMultipleMethods = (function (_ref5) { value: function m2() {} }]); return _class5; -})()); \ No newline at end of file +})()); diff --git a/test/core/fixtures/transformation/es6.classes/super-class-id-member-expression/expected.js b/test/core/fixtures/transformation/es6.classes/super-class-id-member-expression/expected.js index 3aadfc32b9..6394f2df5f 100644 --- a/test/core/fixtures/transformation/es6.classes/super-class-id-member-expression/expected.js +++ b/test/core/fixtures/transformation/es6.classes/super-class-id-member-expression/expected.js @@ -1,21 +1,23 @@ "use strict"; var BaseController = (function (_Chaplin$Controller) { + babelHelpers.inherits(BaseController, _Chaplin$Controller); + function BaseController() { babelHelpers.classCallCheck(this, BaseController); babelHelpers.get(Object.getPrototypeOf(BaseController.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(BaseController, _Chaplin$Controller); return BaseController; })(Chaplin.Controller); var BaseController2 = (function (_Chaplin$Controller$Another) { + babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another); + function BaseController2() { babelHelpers.classCallCheck(this, BaseController2); babelHelpers.get(Object.getPrototypeOf(BaseController2.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(BaseController2, _Chaplin$Controller$Another); return BaseController2; -})(Chaplin.Controller.Another); \ No newline at end of file +})(Chaplin.Controller.Another); diff --git a/test/core/fixtures/transformation/es6.classes/super-class/expected.js b/test/core/fixtures/transformation/es6.classes/super-class/expected.js index 9f13499a4a..3ffa78e87c 100644 --- a/test/core/fixtures/transformation/es6.classes/super-class/expected.js +++ b/test/core/fixtures/transformation/es6.classes/super-class/expected.js @@ -1,11 +1,12 @@ "use strict"; var Test = (function (_Foo) { + babelHelpers.inherits(Test, _Foo); + function Test() { babelHelpers.classCallCheck(this, Test); babelHelpers.get(Object.getPrototypeOf(Test.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(Test, _Foo); return Test; -})(Foo); \ No newline at end of file +})(Foo); diff --git a/test/core/fixtures/transformation/es6.parameters/rest-nested-iife/expected.js b/test/core/fixtures/transformation/es6.parameters/rest-nested-iife/expected.js index 509591d150..438a6ffbeb 100644 --- a/test/core/fixtures/transformation/es6.parameters/rest-nested-iife/expected.js +++ b/test/core/fixtures/transformation/es6.parameters/rest-nested-iife/expected.js @@ -14,14 +14,14 @@ function broken(x) { if (true) { var _ret = (function () { var Foo = (function (_Bar) { + _inherits(Foo, _Bar); + function Foo() { _classCallCheck(this, Foo); _get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments); } - _inherits(Foo, _Bar); - return Foo; })(Bar); diff --git a/test/core/fixtures/transformation/es7.class-properties/derived/expected.js b/test/core/fixtures/transformation/es7.class-properties/derived/expected.js index 0362065035..221a69fd86 100644 --- a/test/core/fixtures/transformation/es7.class-properties/derived/expected.js +++ b/test/core/fixtures/transformation/es7.class-properties/derived/expected.js @@ -1,12 +1,13 @@ "use strict"; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo() { babelHelpers.classCallCheck(this, Foo); babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments); this.bar = "foo"; } - babelHelpers.inherits(Foo, _Bar); return Foo; -})(Bar); \ No newline at end of file +})(Bar); diff --git a/test/core/fixtures/transformation/es7.class-properties/super-expression/expected.js b/test/core/fixtures/transformation/es7.class-properties/super-expression/expected.js index 0dc028074d..d7eb6e3d51 100644 --- a/test/core/fixtures/transformation/es7.class-properties/super-expression/expected.js +++ b/test/core/fixtures/transformation/es7.class-properties/super-expression/expected.js @@ -1,6 +1,8 @@ "use strict"; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo() { var _temp; @@ -9,6 +11,5 @@ var Foo = (function (_Bar) { foo((_temp = babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this), this.bar = "foo", _temp)); } - babelHelpers.inherits(Foo, _Bar); return Foo; -})(Bar); \ No newline at end of file +})(Bar); diff --git a/test/core/fixtures/transformation/es7.class-properties/super-statement/expected.js b/test/core/fixtures/transformation/es7.class-properties/super-statement/expected.js index 17c7c8dfb8..37cf39e659 100644 --- a/test/core/fixtures/transformation/es7.class-properties/super-statement/expected.js +++ b/test/core/fixtures/transformation/es7.class-properties/super-statement/expected.js @@ -1,6 +1,8 @@ "use strict"; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo() { babelHelpers.classCallCheck(this, Foo); @@ -8,6 +10,5 @@ var Foo = (function (_Bar) { this.bar = "foo"; } - babelHelpers.inherits(Foo, _Bar); return Foo; -})(Bar); \ No newline at end of file +})(Bar); diff --git a/test/core/fixtures/transformation/es7.decorators/class-super/expected.js b/test/core/fixtures/transformation/es7.decorators/class-super/expected.js index 4150b8a957..00c54848e8 100644 --- a/test/core/fixtures/transformation/es7.decorators/class-super/expected.js +++ b/test/core/fixtures/transformation/es7.decorators/class-super/expected.js @@ -1,27 +1,29 @@ "use strict"; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo() { babelHelpers.classCallCheck(this, _Foo); babelHelpers.get(Object.getPrototypeOf(_Foo.prototype), "constructor", this).call(this); } - babelHelpers.inherits(Foo, _Bar); var _Foo = Foo; Foo = bar(Foo) || Foo; return Foo; })(Bar); var Foo2 = (function (_Bar2) { + babelHelpers.inherits(Foo2, _Bar2); + function Foo2() { babelHelpers.classCallCheck(this, _Foo2); babelHelpers.get(Object.getPrototypeOf(_Foo2.prototype), "constructor", this).call(this); } - babelHelpers.inherits(Foo2, _Bar2); var _Foo2 = Foo2; Foo2 = bar(Foo2) || Foo2; return Foo2; -})(Bar); \ No newline at end of file +})(Bar); diff --git a/test/core/fixtures/transformation/misc/regression-1155/expected.js b/test/core/fixtures/transformation/misc/regression-1155/expected.js index 9acd4f71a6..6559a17448 100644 --- a/test/core/fixtures/transformation/misc/regression-1155/expected.js +++ b/test/core/fixtures/transformation/misc/regression-1155/expected.js @@ -1,6 +1,8 @@ "use strict"; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo(options) { babelHelpers.classCallCheck(this, Foo); @@ -11,6 +13,5 @@ var Foo = (function (_Bar) { babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this, parentOptions); } - babelHelpers.inherits(Foo, _Bar); return Foo; })(Bar); diff --git a/test/core/fixtures/transformation/react/optimisation.react.constant-elements/expected.js b/test/core/fixtures/transformation/react/optimisation.react.constant-elements/expected.js index 66274bd2b5..32b1dc88bc 100644 --- a/test/core/fixtures/transformation/react/optimisation.react.constant-elements/expected.js +++ b/test/core/fixtures/transformation/react/optimisation.react.constant-elements/expected.js @@ -9,12 +9,13 @@ var _ref = React.createElement( ); var App = (function (_React$Component) { + babelHelpers.inherits(App, _React$Component); + function App() { babelHelpers.classCallCheck(this, App); babelHelpers.get(Object.getPrototypeOf(App.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(App, _React$Component); babelHelpers.createClass(App, [{ key: "render", value: function render() { @@ -36,4 +37,4 @@ var App = (function (_React$Component) { } }]); return App; -})(React.Component); \ No newline at end of file +})(React.Component); diff --git a/test/core/fixtures/transformation/spec.function-name/modules-3/expected.js b/test/core/fixtures/transformation/spec.function-name/modules-3/expected.js index 7cd9ac5a1a..9dbe20a4d6 100644 --- a/test/core/fixtures/transformation/spec.function-name/modules-3/expected.js +++ b/test/core/fixtures/transformation/spec.function-name/modules-3/expected.js @@ -7,12 +7,13 @@ Object.defineProperty(exports, "__esModule", { var _store = require("./store"); var Login = (function (_React$Component) { + babelHelpers.inherits(Login, _React$Component); + function Login() { babelHelpers.classCallCheck(this, Login); babelHelpers.get(Object.getPrototypeOf(Login.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(Login, _React$Component); babelHelpers.createClass(Login, [{ key: "getForm", value: function getForm() { @@ -23,4 +24,4 @@ var Login = (function (_React$Component) { })(React.Component); exports["default"] = Login; -module.exports = exports["default"]; \ No newline at end of file +module.exports = exports["default"]; diff --git a/test/core/fixtures/transformation/spec.proto-to-assign/class/expected.js b/test/core/fixtures/transformation/spec.proto-to-assign/class/expected.js index 9e179061d5..4e1f073366 100644 --- a/test/core/fixtures/transformation/spec.proto-to-assign/class/expected.js +++ b/test/core/fixtures/transformation/spec.proto-to-assign/class/expected.js @@ -1,11 +1,12 @@ "use strict"; var Foo = (function (_Bar) { + babelHelpers.inherits(Foo, _Bar); + function Foo() { babelHelpers.classCallCheck(this, Foo); babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).apply(this, arguments); } - babelHelpers.inherits(Foo, _Bar); return Foo; -})(Bar); \ No newline at end of file +})(Bar);