We were using `Object.create` to setup the prototype chain at the start of the class definition, which lead to #7771. I was a bit worried about a speed hit, but it seems everyone optimizes the two patterns the same way. https://jsbench.github.io/#f9fca52407643d96458a35763b201215 Fixes #7771.
41 lines
889 B
JavaScript
41 lines
889 B
JavaScript
"use strict";
|
|
|
|
var Hello =
|
|
/*#__PURE__*/
|
|
function () {
|
|
function Hello() {
|
|
babelHelpers.classCallCheck(this, Hello);
|
|
}
|
|
|
|
babelHelpers.createClass(Hello, [{
|
|
key: "toString",
|
|
value: function toString() {
|
|
return 'hello';
|
|
}
|
|
}]);
|
|
return Hello;
|
|
}();
|
|
|
|
var Outer =
|
|
/*#__PURE__*/
|
|
function (_Hello) {
|
|
function Outer() {
|
|
var _this;
|
|
|
|
babelHelpers.classCallCheck(this, Outer);
|
|
_this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Outer).call(this));
|
|
var Inner = {
|
|
[babelHelpers.get(babelHelpers.getPrototypeOf(Outer.prototype), "toString", babelHelpers.assertThisInitialized(_this)).call(_this)]() {
|
|
return 'hello';
|
|
}
|
|
|
|
};
|
|
return babelHelpers.possibleConstructorReturn(_this, Inner);
|
|
}
|
|
|
|
babelHelpers.inherits(Outer, _Hello);
|
|
return Outer;
|
|
}(Hello);
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|