Fix class inheritance in IE10 (#7969)

* Revert "Move subclass inheritance to end (#7772)"

This reverts commit f8ab9466d3.

* Only use getPrototypeOf if setPrototypeOf is implemented

* Update fixtures

* Helpers updates

* Update fixtures

* Fall back to getPrototypeOf

* Update fixtures
This commit is contained in:
Justin Ridgewell
2018-05-23 16:21:21 -04:00
committed by Henry Zhu
parent ffe04d9195
commit 2af7a33c4e
151 changed files with 461 additions and 487 deletions

View File

@@ -3,6 +3,8 @@ var Test =
function (_Foo) {
"use strict";
babelHelpers.inherits(Test, _Foo);
function Test() {
var _babelHelpers$getProt, _babelHelpers$get;
@@ -42,6 +44,5 @@ function (_Foo) {
(_babelHelpers$get3 = babelHelpers.get(babelHelpers.getPrototypeOf(Test), "foo", this)).call.apply(_babelHelpers$get3, [this, "test"].concat(Array.prototype.slice.call(arguments)));
}
}]);
babelHelpers.inherits(Test, _Foo);
return Test;
}(Foo);

View File

@@ -3,6 +3,8 @@ var Test =
function (_Foo) {
"use strict";
babelHelpers.inherits(Test, _Foo);
function Test() {
var _this;
@@ -13,6 +15,5 @@ function (_Foo) {
return _this;
}
babelHelpers.inherits(Test, _Foo);
return Test;
}(Foo);

View File

@@ -3,6 +3,8 @@ var Test =
function (_Foo) {
"use strict";
babelHelpers.inherits(Test, _Foo);
function Test() {
var _this;
@@ -19,6 +21,5 @@ function (_Foo) {
return babelHelpers.get(babelHelpers.getPrototypeOf(Test), "wow", this).call(this);
}
}]);
babelHelpers.inherits(Test, _Foo);
return Test;
}(Foo);

View File

@@ -10,6 +10,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -19,7 +21,6 @@ function (_Bar) {
return _this;
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -12,6 +14,5 @@ function (_Bar) {
}));
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -11,6 +13,5 @@ function (_Bar) {
return babelHelpers.possibleConstructorReturn(_this);
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -14,6 +16,5 @@ function (_Bar) {
return babelHelpers.possibleConstructorReturn(_this);
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -13,6 +15,5 @@ function (_Bar) {
return babelHelpers.possibleConstructorReturn(_this);
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -10,6 +12,5 @@ function (_Bar) {
return babelHelpers.possibleConstructorReturn(_this);
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Child =
function (_Base) {
"use strict";
babelHelpers.inherits(Child, _Base);
function Child() {
var _this;
@@ -10,6 +12,5 @@ function (_Base) {
return babelHelpers.possibleConstructorReturn(_this, false);
}
babelHelpers.inherits(Child, _Base);
return Child;
}(Base);

View File

@@ -3,6 +3,8 @@ var Child =
function (_Base) {
"use strict";
babelHelpers.inherits(Child, _Base);
function Child() {
var _this;
@@ -10,6 +12,5 @@ function (_Base) {
return babelHelpers.possibleConstructorReturn(_this, {});
}
babelHelpers.inherits(Child, _Base);
return Child;
}(Base);

View File

@@ -1,12 +1,13 @@
var _default =
/*#__PURE__*/
function (_A) {
babelHelpers.inherits(_default, _A);
function _default() {
babelHelpers.classCallCheck(this, _default);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(_default).apply(this, arguments));
}
babelHelpers.inherits(_default, _A);
return _default;
}(A);

View File

@@ -13,6 +13,8 @@ var Hello = function Hello() {
var Outer =
/*#__PURE__*/
function (_Hello) {
babelHelpers.inherits(Outer, _Hello);
function Outer() {
var _this2 = this;
@@ -39,7 +41,6 @@ function (_Hello) {
return babelHelpers.possibleConstructorReturn(_this, new Inner());
}
babelHelpers.inherits(Outer, _Hello);
return Outer;
}(Hello);

View File

@@ -19,6 +19,8 @@ function () {
var Outer =
/*#__PURE__*/
function (_Hello) {
babelHelpers.inherits(Outer, _Hello);
function Outer() {
var _this;
@@ -44,7 +46,6 @@ function (_Hello) {
return babelHelpers.possibleConstructorReturn(_this, new Inner());
}
babelHelpers.inherits(Outer, _Hello);
return Outer;
}(Hello);

View File

@@ -13,6 +13,8 @@ var Hello = function Hello() {
var Outer =
/*#__PURE__*/
function (_Hello) {
babelHelpers.inherits(Outer, _Hello);
function Outer() {
var _this;
@@ -26,7 +28,6 @@ function (_Hello) {
return babelHelpers.possibleConstructorReturn(_this, Inner);
}
babelHelpers.inherits(Outer, _Hello);
return Outer;
}(Hello);

View File

@@ -19,6 +19,8 @@ function () {
var Outer =
/*#__PURE__*/
function (_Hello) {
babelHelpers.inherits(Outer, _Hello);
function Outer() {
var _this;
@@ -33,7 +35,6 @@ function (_Hello) {
return babelHelpers.possibleConstructorReturn(_this, Inner);
}
babelHelpers.inherits(Outer, _Hello);
return Outer;
}(Hello);

View File

@@ -1,14 +0,0 @@
class Base {
get test() {
}
}
class Sub extends Base {
// Redefining method here
test() {
return 1;
}
}
expect(new Sub().test()).toBe(1);

View File

@@ -1,14 +0,0 @@
class Base {
get test() {
}
}
class Sub extends Base {
// Redefining method here
test() {
return 1;
}
}
expect(new Sub().test()).toBe(1);

View File

@@ -1,38 +0,0 @@
var Base =
/*#__PURE__*/
function () {
"use strict";
function Base() {
babelHelpers.classCallCheck(this, Base);
}
babelHelpers.createClass(Base, [{
key: "test",
get: function get() {}
}]);
return Base;
}();
var Sub =
/*#__PURE__*/
function (_Base) {
"use strict";
function Sub() {
babelHelpers.classCallCheck(this, Sub);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Sub).apply(this, arguments));
}
babelHelpers.createClass(Sub, [{
key: "test",
// Redefining method here
value: function test() {
return 1;
}
}]);
babelHelpers.inherits(Sub, _Base);
return Sub;
}(Base);
expect(new Sub().test()).toBe(1);

View File

@@ -3,12 +3,13 @@ var TestEmpty =
function (_ref) {
"use strict";
babelHelpers.inherits(TestEmpty, _ref);
function TestEmpty() {
babelHelpers.classCallCheck(this, TestEmpty);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestEmpty).apply(this, arguments));
}
babelHelpers.inherits(TestEmpty, _ref);
return TestEmpty;
}(
/*#__PURE__*/
@@ -27,12 +28,13 @@ var TestConstructorOnly =
function (_ref2) {
"use strict";
babelHelpers.inherits(TestConstructorOnly, _ref2);
function TestConstructorOnly() {
babelHelpers.classCallCheck(this, TestConstructorOnly);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestConstructorOnly).apply(this, arguments));
}
babelHelpers.inherits(TestConstructorOnly, _ref2);
return TestConstructorOnly;
}(
/*#__PURE__*/
@@ -51,12 +53,13 @@ var TestMethodOnly =
function (_ref3) {
"use strict";
babelHelpers.inherits(TestMethodOnly, _ref3);
function TestMethodOnly() {
babelHelpers.classCallCheck(this, TestMethodOnly);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestMethodOnly).apply(this, arguments));
}
babelHelpers.inherits(TestMethodOnly, _ref3);
return TestMethodOnly;
}(
/*#__PURE__*/
@@ -79,12 +82,13 @@ var TestConstructorAndMethod =
function (_ref4) {
"use strict";
babelHelpers.inherits(TestConstructorAndMethod, _ref4);
function TestConstructorAndMethod() {
babelHelpers.classCallCheck(this, TestConstructorAndMethod);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestConstructorAndMethod).apply(this, arguments));
}
babelHelpers.inherits(TestConstructorAndMethod, _ref4);
return TestConstructorAndMethod;
}(
/*#__PURE__*/
@@ -107,12 +111,13 @@ var TestMultipleMethods =
function (_ref5) {
"use strict";
babelHelpers.inherits(TestMultipleMethods, _ref5);
function TestMultipleMethods() {
babelHelpers.classCallCheck(this, TestMultipleMethods);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestMultipleMethods).apply(this, arguments));
}
babelHelpers.inherits(TestMultipleMethods, _ref5);
return TestMultipleMethods;
}(
/*#__PURE__*/

View File

@@ -3,12 +3,13 @@ var BaseController =
function (_Chaplin$Controller) {
"use strict";
babelHelpers.inherits(BaseController, _Chaplin$Controller);
function BaseController() {
babelHelpers.classCallCheck(this, BaseController);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(BaseController).apply(this, arguments));
}
babelHelpers.inherits(BaseController, _Chaplin$Controller);
return BaseController;
}(Chaplin.Controller);
@@ -17,11 +18,12 @@ var BaseController2 =
function (_Chaplin$Controller$A) {
"use strict";
babelHelpers.inherits(BaseController2, _Chaplin$Controller$A);
function BaseController2() {
babelHelpers.classCallCheck(this, BaseController2);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(BaseController2).apply(this, arguments));
}
babelHelpers.inherits(BaseController2, _Chaplin$Controller$A);
return BaseController2;
}(Chaplin.Controller.Another);

View File

@@ -3,11 +3,12 @@ var Test =
function (_Foo) {
"use strict";
babelHelpers.inherits(Test, _Foo);
function Test() {
babelHelpers.classCallCheck(this, Test);
return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Test).apply(this, arguments));
}
babelHelpers.inherits(Test, _Foo);
return Test;
}(Foo);

View File

@@ -1,24 +1,26 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } _setPrototypeOf(subClass.prototype, superClass && superClass.prototype); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
_inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -29,7 +31,5 @@ function (_Bar) {
return _this;
}
_inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -1,24 +1,26 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } _setPrototypeOf(subClass.prototype, superClass && superClass.prototype); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var Foo =
/*#__PURE__*/
function (_Bar) {
"use strict";
_inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -29,7 +31,5 @@ function (_Bar) {
return _this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
}
_inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -14,6 +16,5 @@ function (_Bar) {
return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this));
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -15,6 +17,5 @@ function (_Bar) {
return _this;
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -13,6 +15,5 @@ function (_Bar) {
return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this));
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -11,6 +13,5 @@ function (_Bar) {
return _this;
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -10,6 +12,5 @@ function (_Bar) {
return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this, babelHelpers.assertThisInitialized(babelHelpers.assertThisInitialized(_this))));
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -14,6 +16,5 @@ function (_Bar) {
return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this));
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -15,6 +17,5 @@ function (_Bar) {
return _this;
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -11,6 +13,5 @@ function (_Bar) {
return babelHelpers.possibleConstructorReturn(_this);
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);

View File

@@ -3,6 +3,8 @@ var Foo =
function (_Bar) {
"use strict";
babelHelpers.inherits(Foo, _Bar);
function Foo() {
var _this;
@@ -11,6 +13,5 @@ function (_Bar) {
return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this));
}
babelHelpers.inherits(Foo, _Bar);
return Foo;
}(Bar);