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.
34 lines
635 B
JavaScript
34 lines
635 B
JavaScript
"use strict";
|
|
|
|
var Hello = function Hello() {
|
|
babelHelpers.classCallCheck(this, Hello);
|
|
return {
|
|
toString() {
|
|
return 'hello';
|
|
}
|
|
|
|
};
|
|
};
|
|
|
|
var Outer =
|
|
/*#__PURE__*/
|
|
function (_Hello) {
|
|
function Outer() {
|
|
var _this;
|
|
|
|
babelHelpers.classCallCheck(this, Outer);
|
|
var Inner = {
|
|
[_this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Outer).call(this))]() {
|
|
return 'hello';
|
|
}
|
|
|
|
};
|
|
return babelHelpers.possibleConstructorReturn(_this, Inner);
|
|
}
|
|
|
|
babelHelpers.inherits(Outer, _Hello);
|
|
return Outer;
|
|
}(Hello);
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|