Daniel Tschinder 10cd6519d8 Fix class inheritance in IE <=10 (T3041) (#3527)
* Fix class inheritance in IE9 & IE10 (T3041)

Internet Explorer 9&10 do not support __proto__ at all, don't have
Object.setPrototypeOf(), but have Object.getPrototypeOf().

Because of this setting the prototype is not possible, which makes the
babelHelpers.inherits() function to set __proto__ although not supported.

Afterwards Object.getPrototypeOf() is used, but this one is not
respecting the "custom" property __proto__ that we set.

The solution is to check for __proto__ first and afterwards fallback to
Object.getPrototypeOf().

* Do the same logic in babel-helper-replace-supers

* Fix tests

* Extract creation of prototype nodes to small helper
2016-08-23 15:08:44 -04:00

100 lines
2.7 KiB
JavaScript

var TestEmpty = function (_ref) {
babelHelpers.inherits(TestEmpty, _ref);
function TestEmpty() {
babelHelpers.classCallCheck(this, TestEmpty);
return babelHelpers.possibleConstructorReturn(this, (TestEmpty.__proto__ || Object.getPrototypeOf(TestEmpty)).apply(this, arguments));
}
return TestEmpty;
}(function () {
function _class() {
babelHelpers.classCallCheck(this, _class);
}
return _class;
}());
var TestConstructorOnly = function (_ref2) {
babelHelpers.inherits(TestConstructorOnly, _ref2);
function TestConstructorOnly() {
babelHelpers.classCallCheck(this, TestConstructorOnly);
return babelHelpers.possibleConstructorReturn(this, (TestConstructorOnly.__proto__ || Object.getPrototypeOf(TestConstructorOnly)).apply(this, arguments));
}
return TestConstructorOnly;
}(function () {
function _class2() {
babelHelpers.classCallCheck(this, _class2);
}
return _class2;
}());
var TestMethodOnly = function (_ref3) {
babelHelpers.inherits(TestMethodOnly, _ref3);
function TestMethodOnly() {
babelHelpers.classCallCheck(this, TestMethodOnly);
return babelHelpers.possibleConstructorReturn(this, (TestMethodOnly.__proto__ || Object.getPrototypeOf(TestMethodOnly)).apply(this, arguments));
}
return TestMethodOnly;
}(function () {
function _class3() {
babelHelpers.classCallCheck(this, _class3);
}
babelHelpers.createClass(_class3, [{
key: "method",
value: function method() {}
}]);
return _class3;
}());
var TestConstructorAndMethod = function (_ref4) {
babelHelpers.inherits(TestConstructorAndMethod, _ref4);
function TestConstructorAndMethod() {
babelHelpers.classCallCheck(this, TestConstructorAndMethod);
return babelHelpers.possibleConstructorReturn(this, (TestConstructorAndMethod.__proto__ || Object.getPrototypeOf(TestConstructorAndMethod)).apply(this, arguments));
}
return TestConstructorAndMethod;
}(function () {
function _class4() {
babelHelpers.classCallCheck(this, _class4);
}
babelHelpers.createClass(_class4, [{
key: "method",
value: function method() {}
}]);
return _class4;
}());
var TestMultipleMethods = function (_ref5) {
babelHelpers.inherits(TestMultipleMethods, _ref5);
function TestMultipleMethods() {
babelHelpers.classCallCheck(this, TestMultipleMethods);
return babelHelpers.possibleConstructorReturn(this, (TestMultipleMethods.__proto__ || Object.getPrototypeOf(TestMultipleMethods)).apply(this, arguments));
}
return TestMultipleMethods;
}(function () {
function _class5() {
babelHelpers.classCallCheck(this, _class5);
}
babelHelpers.createClass(_class5, [{
key: "m1",
value: function m1() {}
}, {
key: "m2",
value: function m2() {}
}]);
return _class5;
}());