From 450a1678f23d6bfff8b0219d828eecafbb3b318c Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Fri, 6 Apr 2018 02:54:08 +0100 Subject: [PATCH] Use getProto and setProto helpers (#7675) Depends on #7674. --- .../misc/regression-1155/output.js | 2 +- .../babel-helper-replace-supers/src/index.js | 20 +++++--------- .../fixtures/public-loose/derived/output.js | 2 +- .../fixtures/public-loose/foobar/output.js | 2 +- .../public-loose/regression-T6719/output.js | 2 +- .../public-loose/super-call/output.js | 2 +- .../public-loose/super-expression/output.js | 2 +- .../public-loose/super-statement/output.js | 2 +- .../super-with-collision/output.js | 2 +- .../test/fixtures/public/derived/output.js | 2 +- .../test/fixtures/public/foobar/output.js | 2 +- .../public/regression-T6719/output.js | 2 +- .../test/fixtures/public/super-call/output.js | 4 +-- .../public/super-expression/output.js | 2 +- .../fixtures/public/super-statement/output.js | 2 +- .../public/super-with-collision/output.js | 2 +- .../test/fixtures/regression/6154/output.js | 8 +++--- .../test/fixtures/regression/T6719/output.js | 2 +- .../test/fixtures/regression/7030/output.js | 4 ++- .../src/transformClass.js | 17 +++--------- .../extend-builtins/shadowed/output.js | 2 +- .../fixtures/extend-builtins/spec/output.js | 2 +- .../test/fixtures/regression/2663/output.js | 2 +- .../test/fixtures/regression/2694/output.js | 4 +-- .../test/fixtures/regression/2775/output.js | 2 +- .../test/fixtures/regression/3028/output.js | 4 +-- .../test/fixtures/regression/5817/output.js | 2 +- .../test/fixtures/regression/T2494/output.js | 2 +- .../test/fixtures/regression/T2997/output.js | 2 +- .../test/fixtures/regression/T7537/output.js | 4 ++- .../spec/accessing-super-class/output.js | 26 +++++++++---------- .../spec/accessing-super-properties/output.js | 6 ++--- .../spec/calling-super-properties/output.js | 8 +++--- .../test/fixtures/spec/constructor/output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../spec/export-super-class/output.mjs | 2 +- .../spec/super-class-anonymous/output.js | 10 +++---- .../output.js | 4 +-- .../test/fixtures/spec/super-class/output.js | 2 +- .../spec/super-function-fallback/output.js | 2 +- .../output.js | 2 +- .../output.js | 4 +-- .../output.js | 6 ++--- .../output.js | 4 +-- .../output.js | 4 +-- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../test/fixtures/regression/4349/output.js | 2 +- .../function-name/modules-3/output.js | 2 +- .../object-super/statically-bound/output.js | 2 +- .../super-exponentiation/output.js | 2 +- .../parameters/rest-nested-iife/output.js | 2 +- .../regression/6057-expanded/output.js | 6 +++-- .../output.js | 2 +- .../useBuiltIns-useESModules/output.js | 4 ++- .../use-options/useBuiltIns/output.js | 4 ++- .../use-options/useESModules/output.js | 6 ++--- .../plugins-integration/issue-7527/output.js | 2 +- 64 files changed, 117 insertions(+), 126 deletions(-) diff --git a/packages/babel-core/test/fixtures/transformation/misc/regression-1155/output.js b/packages/babel-core/test/fixtures/transformation/misc/regression-1155/output.js index 021eff14b4..f1349b84f7 100644 --- a/packages/babel-core/test/fixtures/transformation/misc/regression-1155/output.js +++ b/packages/babel-core/test/fixtures/transformation/misc/regression-1155/output.js @@ -11,7 +11,7 @@ function (_Bar) { this; }; - return babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this, parentOptions)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this, parentOptions)); } return Foo; diff --git a/packages/babel-helper-replace-supers/src/index.js b/packages/babel-helper-replace-supers/src/index.js index 910e4088ce..22bfce95a3 100644 --- a/packages/babel-helper-replace-supers/src/index.js +++ b/packages/babel-helper-replace-supers/src/index.js @@ -28,22 +28,14 @@ function isMemberExpressionSuper(node) { * * CLASS.prototype.__proto__ || Object.getPrototypeOf(CLASS.prototype) */ -function getPrototypeOfExpression(objectRef, isStatic) { +function getPrototypeOfExpression(objectRef, isStatic, file) { const targetRef = isStatic ? objectRef : t.memberExpression(objectRef, t.identifier("prototype")); - return t.logicalExpression( - "||", - t.memberExpression(targetRef, t.identifier("__proto__")), - t.callExpression( - t.memberExpression( - t.identifier("Object"), - t.identifier("getPrototypeOf"), - ), - [t.cloneNode(targetRef)], - ), - ); + return t.callExpression(file.addHelper("getPrototypeOf"), [ + t.cloneNode(targetRef), + ]); } const visitor = { @@ -160,7 +152,7 @@ export default class ReplaceSupers { isComputed: boolean, ): Object { return t.callExpression(this.file.addHelper("set"), [ - getPrototypeOfExpression(this.getObjectRef(), this.isStatic), + getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file), isComputed ? property : t.stringLiteral(property.name), value, t.thisExpression(), @@ -186,7 +178,7 @@ export default class ReplaceSupers { } return t.callExpression(this.file.addHelper("get"), [ - getPrototypeOfExpression(this.getObjectRef(), this.isStatic), + getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file), isComputed ? property : t.stringLiteral(property.name), thisExpr, ]); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/derived/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/derived/output.js index 786decc6f3..3554a0e804 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/derived/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/derived/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _temp, _this; babelHelpers.classCallCheck(this, Foo); - return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this, ...args)), _this.bar = "foo", _temp)); + return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this, ...args)), _this.bar = "foo", _temp)); } return Foo; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/foobar/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/foobar/output.js index f43f546b7c..0fab0c8e95 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/foobar/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/foobar/output.js @@ -7,7 +7,7 @@ function (_Parent) { var _this; babelHelpers.classCallCheck(this, Child); - _this = babelHelpers.possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Child).call(this)); _this.scopedFunctionWithThis = function () { _this.name = {}; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/regression-T6719/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/regression-T6719/output.js index 135dd0301e..c815369e9e 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/regression-T6719/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/regression-T6719/output.js @@ -8,7 +8,7 @@ function withContext(ComposedComponent) { function WithContext() { babelHelpers.classCallCheck(this, WithContext); - return babelHelpers.possibleConstructorReturn(this, (WithContext.__proto__ || Object.getPrototypeOf(WithContext)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(WithContext).apply(this, arguments)); } return WithContext; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-call/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-call/output.js index ae8920c830..201ad4d5dc 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-call/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-call/output.js @@ -23,7 +23,7 @@ function (_A) { var _temp, _this; babelHelpers.classCallCheck(this, B); - return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, (B.__proto__ || Object.getPrototypeOf(B)).call(this, ...args)), _this.foo = babelHelpers.get(B.prototype.__proto__ || Object.getPrototypeOf(B.prototype), "foo", babelHelpers.assertThisInitialized(_this)).call(_this), _temp)); + return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(B).call(this, ...args)), _this.foo = babelHelpers.get(babelHelpers.getPrototypeOf(B.prototype), "foo", babelHelpers.assertThisInitialized(_this)).call(_this), _temp)); } return B; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-expression/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-expression/output.js index 96cdd19207..0aff7fc69f 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-expression/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-expression/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _temp, _this; babelHelpers.classCallCheck(this, Foo); - foo((_temp = _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)), _this.bar = "foo", _temp)); + foo((_temp = _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)), _this.bar = "foo", _temp)); return _this; } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-statement/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-statement/output.js index 8937610b15..e286be95c0 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-statement/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-statement/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _this; babelHelpers.classCallCheck(this, Foo); - _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); _this.bar = "foo"; return _this; } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-with-collision/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-with-collision/output.js index 9b483cdad6..bd91aee83d 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-with-collision/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public-loose/super-with-collision/output.js @@ -1,5 +1,5 @@ var A = function A(_force) { babelHelpers.classCallCheck(this, A); this.force = force; - this.foo = babelHelpers.get(A.prototype.__proto__ || Object.getPrototypeOf(A.prototype), "method", babelHelpers.assertThisInitialized(this)).call(this); + this.foo = babelHelpers.get(babelHelpers.getPrototypeOf(A.prototype), "method", babelHelpers.assertThisInitialized(this)).call(this); }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/derived/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/derived/output.js index 5615c3cffb..332f2cb090 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/derived/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/derived/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _temp, _this; babelHelpers.classCallCheck(this, Foo); - return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this, ...args)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", { + return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this, ...args)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", { configurable: true, enumerable: true, writable: true, diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/foobar/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/foobar/output.js index 4c8e9df931..6404800a00 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/foobar/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/foobar/output.js @@ -7,7 +7,7 @@ function (_Parent) { var _this; babelHelpers.classCallCheck(this, Child); - _this = babelHelpers.possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Child).call(this)); Object.defineProperty(babelHelpers.assertThisInitialized(_this), "scopedFunctionWithThis", { configurable: true, enumerable: true, diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/regression-T6719/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/regression-T6719/output.js index e953730b64..874bc077bb 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/regression-T6719/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/regression-T6719/output.js @@ -8,7 +8,7 @@ function withContext(ComposedComponent) { function WithContext() { babelHelpers.classCallCheck(this, WithContext); - return babelHelpers.possibleConstructorReturn(this, (WithContext.__proto__ || Object.getPrototypeOf(WithContext)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(WithContext).apply(this, arguments)); } return WithContext; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-call/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-call/output.js index edd181b05b..365452158f 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-call/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-call/output.js @@ -23,11 +23,11 @@ function (_A) { var _temp, _this; babelHelpers.classCallCheck(this, B); - return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, (B.__proto__ || Object.getPrototypeOf(B)).call(this, ...args)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "foo", { + return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(B).call(this, ...args)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "foo", { configurable: true, enumerable: true, writable: true, - value: babelHelpers.get(B.prototype.__proto__ || Object.getPrototypeOf(B.prototype), "foo", babelHelpers.assertThisInitialized(_this)).call(_this) + value: babelHelpers.get(babelHelpers.getPrototypeOf(B.prototype), "foo", babelHelpers.assertThisInitialized(_this)).call(_this) }), _temp)); } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-expression/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-expression/output.js index aaa16b44ee..942670c9bf 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-expression/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-expression/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _temp, _this; babelHelpers.classCallCheck(this, Foo); - foo((_temp = _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", { + foo((_temp = _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", { configurable: true, enumerable: true, writable: true, diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-statement/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-statement/output.js index 5c9c26143b..c28e24fbb3 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-statement/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-statement/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _this; babelHelpers.classCallCheck(this, Foo); - _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); Object.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", { configurable: true, enumerable: true, diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-with-collision/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-with-collision/output.js index 3c06b4ed8c..f172e7c8b8 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-with-collision/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/public/super-with-collision/output.js @@ -10,6 +10,6 @@ var A = function A(_force) { configurable: true, enumerable: true, writable: true, - value: babelHelpers.get(A.prototype.__proto__ || Object.getPrototypeOf(A.prototype), "method", babelHelpers.assertThisInitialized(this)).call(this) + value: babelHelpers.get(babelHelpers.getPrototypeOf(A.prototype), "method", babelHelpers.assertThisInitialized(this)).call(this) }); }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/6154/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/6154/output.js index f851e5708f..d6b68f2eee 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/6154/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/6154/output.js @@ -27,7 +27,7 @@ var Test = function Test() { _inherits(Other, _Test); function Other() { - var _ref; + var _getPrototypeOf2; var _temp, _this; @@ -37,12 +37,12 @@ var Test = function Test() { args[_key] = arguments[_key]; } - return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = Other.__proto__ || Object.getPrototypeOf(Other)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "a", { + return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Other)).call.apply(_getPrototypeOf2, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "a", { configurable: true, enumerable: true, writable: true, value: function value() { - return _get(Other.prototype.__proto__ || Object.getPrototypeOf(Other.prototype), "test", _assertThisInitialized(_this)); + return _get(_getPrototypeOf(Other.prototype), "test", _assertThisInitialized(_this)); } }), _temp)); } @@ -55,7 +55,7 @@ var Test = function Test() { enumerable: true, writable: true, value: function value() { - return _get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this2)); + return _get(_getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this2)); } }); }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/T6719/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/T6719/output.js index 135dd0301e..c815369e9e 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/T6719/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/T6719/output.js @@ -8,7 +8,7 @@ function withContext(ComposedComponent) { function WithContext() { babelHelpers.classCallCheck(this, WithContext); - return babelHelpers.possibleConstructorReturn(this, (WithContext.__proto__ || Object.getPrototypeOf(WithContext)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(WithContext).apply(this, arguments)); } return WithContext; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/regression/7030/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/regression/7030/output.js index eb18eac531..af11401cc0 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/regression/7030/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/regression/7030/output.js @@ -8,6 +8,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } +function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); } + 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, enumerable: false, 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); } @@ -35,7 +37,7 @@ function (_B) { _classCallCheck(this, A); - _this = _possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this)); + _this = _possibleConstructorReturn(this, _getPrototypeOf(A).call(this)); _this.timestamp = timestamp; _this.moment = moment(timestamp); return _this; diff --git a/packages/babel-plugin-transform-classes/src/transformClass.js b/packages/babel-plugin-transform-classes/src/transformClass.js index 6fd1daa924..8a2c9d6439 100644 --- a/packages/babel-plugin-transform-classes/src/transformClass.js +++ b/packages/babel-plugin-transform-classes/src/transformClass.js @@ -349,20 +349,9 @@ export default function transformClass( call = t.logicalExpression("||", bareSuperNode, t.thisExpression()); } else { bareSuperNode = optimiseCall( - t.logicalExpression( - "||", - t.memberExpression( - t.cloneNode(classState.classRef), - t.identifier("__proto__"), - ), - t.callExpression( - t.memberExpression( - t.identifier("Object"), - t.identifier("getPrototypeOf"), - ), - [t.cloneNode(classState.classRef)], - ), - ), + t.callExpression(classState.file.addHelper("getPrototypeOf"), [ + t.cloneNode(classState.classRef), + ]), t.thisExpression(), bareSuperNode.arguments, ); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/shadowed/output.js b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/shadowed/output.js index f0fd087354..19472774a1 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/shadowed/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/shadowed/output.js @@ -9,7 +9,7 @@ function (_Array) { function List() { babelHelpers.classCallCheck(this, List); - return babelHelpers.possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(List).apply(this, arguments)); } return List; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/spec/output.js b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/spec/output.js index 24e51b61c0..bf7d7d16bd 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/spec/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/spec/output.js @@ -22,7 +22,7 @@ function (_Array) { function List() { _classCallCheck(this, List); - return _possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).apply(this, arguments)); + return _possibleConstructorReturn(this, _getPrototypeOf(List).apply(this, arguments)); } return List; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/2663/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/2663/output.js index 1c2a731682..9efa6b0755 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/2663/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/2663/output.js @@ -21,7 +21,7 @@ function (_EventEmitter) { var _this; babelHelpers.classCallCheck(this, Connection); - _this = babelHelpers.possibleConstructorReturn(this, (Connection.__proto__ || Object.getPrototypeOf(Connection)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Connection).call(this)); _this.isConnected = false; _this.roomId = roomId; // ... diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/2694/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/2694/output.js index ab5839f81d..b90d883f21 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/2694/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/2694/output.js @@ -14,13 +14,13 @@ function (_BaseFoo) { function SubFoo() { babelHelpers.classCallCheck(this, SubFoo); - return babelHelpers.possibleConstructorReturn(this, (SubFoo.__proto__ || Object.getPrototypeOf(SubFoo)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(SubFoo).apply(this, arguments)); } babelHelpers.createClass(SubFoo, null, [{ key: "talk", value: function talk() { - babelHelpers.get(SubFoo.__proto__ || Object.getPrototypeOf(SubFoo), "talk", this).call(this); + babelHelpers.get(babelHelpers.getPrototypeOf(SubFoo), "talk", this).call(this); console.log('SubFoo.talk'); } }]); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/2775/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/2775/output.js index 599a3a5438..dda51585da 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/2775/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/2775/output.js @@ -14,7 +14,7 @@ function (_Component) { function RandomComponent() { babelHelpers.classCallCheck(this, RandomComponent); - return babelHelpers.possibleConstructorReturn(this, (RandomComponent.__proto__ || Object.getPrototypeOf(RandomComponent)).call(this)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(RandomComponent).call(this)); } babelHelpers.createClass(RandomComponent, [{ diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/3028/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/3028/output.js index 2205f40bce..2de289261b 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/3028/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/3028/output.js @@ -18,7 +18,7 @@ function (_b) { var _this; babelHelpers.classCallCheck(this, a1); - _this = babelHelpers.possibleConstructorReturn(this, (a1.__proto__ || Object.getPrototypeOf(a1)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(a1).call(this)); _this.x = function () { return babelHelpers.assertThisInitialized(_this); @@ -39,7 +39,7 @@ function (_b2) { var _this2; babelHelpers.classCallCheck(this, a2); - _this2 = babelHelpers.possibleConstructorReturn(this, (a2.__proto__ || Object.getPrototypeOf(a2)).call(this)); + _this2 = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(a2).call(this)); _this2.x = function () { return babelHelpers.assertThisInitialized(_this2); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/5817/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/5817/output.js index 0abfa635e3..51fb5e2723 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/5817/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/5817/output.js @@ -7,7 +7,7 @@ function (_B) { var _this; babelHelpers.classCallCheck(this, A); - _this = babelHelpers.possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(A).call(this)); _this.arrow1 = function (x) { return x; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/T2494/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/T2494/output.js index 7ee2040344..e343968a10 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/T2494/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/T2494/output.js @@ -6,7 +6,7 @@ var x = { function _class() { babelHelpers.classCallCheck(this, _class); - return babelHelpers.possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(_class).apply(this, arguments)); } return _class; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/T2997/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/T2997/output.js index 8ecfecbaaa..0437a00e7b 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/T2997/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/T2997/output.js @@ -11,7 +11,7 @@ function (_A) { var _this; babelHelpers.classCallCheck(this, B); - return babelHelpers.possibleConstructorReturn(_this, _this = babelHelpers.possibleConstructorReturn(this, (B.__proto__ || Object.getPrototypeOf(B)).call(this))); + return babelHelpers.possibleConstructorReturn(_this, _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(B).call(this))); } return B; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/T7537/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/T7537/output.js index fd483367b2..4f7e6d5549 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/T7537/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/T7537/output.js @@ -4,6 +4,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } +function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); } + 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, enumerable: false, 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); } @@ -26,7 +28,7 @@ function (_B) { _classCallCheck(this, A); - if (track !== undefined) _this = _possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this, track));else _this = _possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this)); + if (track !== undefined) _this = _possibleConstructorReturn(this, _getPrototypeOf(A).call(this, track));else _this = _possibleConstructorReturn(this, _getPrototypeOf(A).call(this)); return _possibleConstructorReturn(_this); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-class/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-class/output.js index f79a960451..d6d2dcd716 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-class/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-class/output.js @@ -4,19 +4,19 @@ function (_Foo) { babelHelpers.inherits(Test, _Foo); function Test() { - var _ref, _babelHelpers$get; + var _babelHelpers$getProt, _babelHelpers$get; var _this; babelHelpers.classCallCheck(this, Test); woops.super.test(); - _this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this)); - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); - _this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).apply(this, arguments)); - _this = babelHelpers.possibleConstructorReturn(this, (_ref = Test.__proto__ || Object.getPrototypeOf(Test)).call.apply(_ref, [this, "test"].concat(Array.prototype.slice.call(arguments)))); - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).apply(_this, arguments); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Test).call(this)); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Test).apply(this, arguments)); + _this = babelHelpers.possibleConstructorReturn(this, (_babelHelpers$getProt = babelHelpers.getPrototypeOf(Test)).call.apply(_babelHelpers$getProt, [this, "test"].concat(Array.prototype.slice.call(arguments)))); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).apply(_this, arguments); - (_babelHelpers$get = babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this))).call.apply(_babelHelpers$get, [_this, "test"].concat(Array.prototype.slice.call(arguments))); + (_babelHelpers$get = babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this))).call.apply(_babelHelpers$get, [_this, "test"].concat(Array.prototype.slice.call(arguments))); return _this; } @@ -26,20 +26,20 @@ function (_Foo) { value: function test() { var _babelHelpers$get2; - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", this).call(this); - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", this).apply(this, arguments); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", this).call(this); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", this).apply(this, arguments); - (_babelHelpers$get2 = babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get2, [this, "test"].concat(Array.prototype.slice.call(arguments))); + (_babelHelpers$get2 = babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get2, [this, "test"].concat(Array.prototype.slice.call(arguments))); } }], [{ key: "foo", value: function foo() { var _babelHelpers$get3; - babelHelpers.get(Test.__proto__ || Object.getPrototypeOf(Test), "foo", this).call(this); - babelHelpers.get(Test.__proto__ || Object.getPrototypeOf(Test), "foo", this).apply(this, arguments); + babelHelpers.get(babelHelpers.getPrototypeOf(Test), "foo", this).call(this); + babelHelpers.get(babelHelpers.getPrototypeOf(Test), "foo", this).apply(this, arguments); - (_babelHelpers$get3 = babelHelpers.get(Test.__proto__ || Object.getPrototypeOf(Test), "foo", this)).call.apply(_babelHelpers$get3, [this, "test"].concat(Array.prototype.slice.call(arguments))); + (_babelHelpers$get3 = babelHelpers.get(babelHelpers.getPrototypeOf(Test), "foo", this)).call.apply(_babelHelpers$get3, [this, "test"].concat(Array.prototype.slice.call(arguments))); } }]); return Test; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-properties/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-properties/output.js index 91f538dcf2..df07a5fe01 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-properties/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-properties/output.js @@ -7,9 +7,9 @@ function (_Foo) { var _this; babelHelpers.classCallCheck(this, Test); - _this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this)); - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)); - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).whatever; + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Test).call(this)); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).whatever; return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/calling-super-properties/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/calling-super-properties/output.js index fe64ce3646..5ff3862b0e 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/calling-super-properties/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/calling-super-properties/output.js @@ -7,16 +7,16 @@ function (_Foo) { var _this; babelHelpers.classCallCheck(this, Test); - _this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this)); - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).whatever(); - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Test).call(this)); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).whatever(); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); return _this; } babelHelpers.createClass(Test, null, [{ key: "test", value: function test() { - return babelHelpers.get(Test.__proto__ || Object.getPrototypeOf(Test), "wow", this).call(this); + return babelHelpers.get(babelHelpers.getPrototypeOf(Test), "wow", this).call(this); } }]); return Test; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/constructor/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/constructor/output.js index 4a2036f774..f43f3601bd 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/constructor/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/constructor/output.js @@ -12,7 +12,7 @@ function (_Bar) { var _this; babelHelpers.classCallCheck(this, Foo); - _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); _this.state = "test"; return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/delay-arrow-function-for-bare-super-derived/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/delay-arrow-function-for-bare-super-derived/output.js index e2cd721fed..18e3b10e80 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/delay-arrow-function-for-bare-super-derived/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/delay-arrow-function-for-bare-super-derived/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _this; babelHelpers.classCallCheck(this, Foo); - return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this, () => { + return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this, () => { _this.test; })); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-2/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-2/output.js index bd43f1f6c5..3fdb9ef413 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-2/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-2/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _this; babelHelpers.classCallCheck(this, Foo); - if (eval("false")) _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + if (eval("false")) _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); return babelHelpers.possibleConstructorReturn(_this); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-3/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-3/output.js index 5ab73330a4..3211f729d8 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-3/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-3/output.js @@ -8,7 +8,7 @@ function (_Bar) { babelHelpers.classCallCheck(this, Foo); - var fn = () => _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + var fn = () => _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); fn(); return babelHelpers.possibleConstructorReturn(_this); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-4/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-4/output.js index 99b2cd7793..0bd914d207 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-4/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-4/output.js @@ -8,7 +8,7 @@ function (_Bar) { babelHelpers.classCallCheck(this, Foo); - var fn = () => _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + var fn = () => _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); return babelHelpers.possibleConstructorReturn(_this); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/export-super-class/output.mjs b/packages/babel-plugin-transform-classes/test/fixtures/spec/export-super-class/output.mjs index 6aafe37c5a..e37e167cda 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/export-super-class/output.mjs +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/export-super-class/output.mjs @@ -5,7 +5,7 @@ function (_A) { function _default() { babelHelpers.classCallCheck(this, _default); - return babelHelpers.possibleConstructorReturn(this, (_default.__proto__ || Object.getPrototypeOf(_default)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(_default).apply(this, arguments)); } return _default; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-anonymous/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-anonymous/output.js index f1e3314520..f12479e6ae 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-anonymous/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-anonymous/output.js @@ -5,7 +5,7 @@ function (_ref) { function TestEmpty() { babelHelpers.classCallCheck(this, TestEmpty); - return babelHelpers.possibleConstructorReturn(this, (TestEmpty.__proto__ || Object.getPrototypeOf(TestEmpty)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestEmpty).apply(this, arguments)); } return TestEmpty; @@ -26,7 +26,7 @@ function (_ref2) { function TestConstructorOnly() { babelHelpers.classCallCheck(this, TestConstructorOnly); - return babelHelpers.possibleConstructorReturn(this, (TestConstructorOnly.__proto__ || Object.getPrototypeOf(TestConstructorOnly)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestConstructorOnly).apply(this, arguments)); } return TestConstructorOnly; @@ -47,7 +47,7 @@ function (_ref3) { function TestMethodOnly() { babelHelpers.classCallCheck(this, TestMethodOnly); - return babelHelpers.possibleConstructorReturn(this, (TestMethodOnly.__proto__ || Object.getPrototypeOf(TestMethodOnly)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestMethodOnly).apply(this, arguments)); } return TestMethodOnly; @@ -72,7 +72,7 @@ function (_ref4) { function TestConstructorAndMethod() { babelHelpers.classCallCheck(this, TestConstructorAndMethod); - return babelHelpers.possibleConstructorReturn(this, (TestConstructorAndMethod.__proto__ || Object.getPrototypeOf(TestConstructorAndMethod)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestConstructorAndMethod).apply(this, arguments)); } return TestConstructorAndMethod; @@ -97,7 +97,7 @@ function (_ref5) { function TestMultipleMethods() { babelHelpers.classCallCheck(this, TestMultipleMethods); - return babelHelpers.possibleConstructorReturn(this, (TestMultipleMethods.__proto__ || Object.getPrototypeOf(TestMultipleMethods)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TestMultipleMethods).apply(this, arguments)); } return TestMultipleMethods; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-id-member-expression/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-id-member-expression/output.js index f6e3221b75..b7198ea8bd 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-id-member-expression/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-id-member-expression/output.js @@ -5,7 +5,7 @@ function (_Chaplin$Controller) { function BaseController() { babelHelpers.classCallCheck(this, BaseController); - return babelHelpers.possibleConstructorReturn(this, (BaseController.__proto__ || Object.getPrototypeOf(BaseController)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(BaseController).apply(this, arguments)); } return BaseController; @@ -18,7 +18,7 @@ function (_Chaplin$Controller$A) { function BaseController2() { babelHelpers.classCallCheck(this, BaseController2); - return babelHelpers.possibleConstructorReturn(this, (BaseController2.__proto__ || Object.getPrototypeOf(BaseController2)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(BaseController2).apply(this, arguments)); } return BaseController2; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class/output.js index 0a4ace74c2..da7a6bd2c0 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class/output.js @@ -5,7 +5,7 @@ function (_Foo) { function Test() { babelHelpers.classCallCheck(this, Test); - return babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Test).apply(this, arguments)); } return Test; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-function-fallback/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-function-fallback/output.js index a1a0e6294a..a78ae7926c 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-function-fallback/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-function-fallback/output.js @@ -1,4 +1,4 @@ var Test = function Test() { babelHelpers.classCallCheck(this, Test); - babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "hasOwnProperty", babelHelpers.assertThisInitialized(this)).call(this, "test"); + babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "hasOwnProperty", babelHelpers.assertThisInitialized(this)).call(this, "test"); }; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super-inline/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super-inline/output.js index 7b3c61c7a9..1ecbab222f 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super-inline/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super-inline/output.js @@ -22,7 +22,7 @@ function (_Bar) { _classCallCheck(this, Foo); - _get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "foo", _assertThisInitialized(_this)).call(_this, _this = _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this))); + _get(_getPrototypeOf(Foo.prototype), "foo", _assertThisInitialized(_this)).call(_this, _this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this))); return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super/output.js index 316858b573..be48d55267 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super/output.js @@ -22,9 +22,9 @@ function (_Bar) { _classCallCheck(this, Foo); - _get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "foo", _assertThisInitialized(_this)).call(_this); + _get(_getPrototypeOf(Foo.prototype), "foo", _assertThisInitialized(_this)).call(_this); - return _this = _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + return _this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this)); } return Foo; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-2/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-2/output.js index 248f97f717..a64a59ae18 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-2/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-2/output.js @@ -8,10 +8,10 @@ function (_Bar) { babelHelpers.classCallCheck(this, Foo); - var t = () => babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); + var t = () => babelHelpers.get(babelHelpers.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); - babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "foo", babelHelpers.assertThisInitialized(_this)).call(_this); - return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + babelHelpers.get(babelHelpers.getPrototypeOf(Foo.prototype), "foo", babelHelpers.assertThisInitialized(_this)).call(_this); + return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); } return Foo; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-3/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-3/output.js index a856f88fbb..0493d62900 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-3/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-3/output.js @@ -8,9 +8,9 @@ function (_Bar) { babelHelpers.classCallCheck(this, Foo); - var t = () => babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); + var t = () => babelHelpers.get(babelHelpers.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); - _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); t(); return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda/output.js index e973f819b9..79a4b98be3 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda/output.js @@ -8,9 +8,9 @@ function (_Bar) { babelHelpers.classCallCheck(this, Foo); - var t = () => babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); + var t = () => babelHelpers.get(babelHelpers.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this); - return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); } return Foo; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/output.js index 9249a2256e..5d1dd6f69c 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _this; babelHelpers.classCallCheck(this, Foo); - babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), (_this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this))).method, babelHelpers.assertThisInitialized(_this)).call(_this); + babelHelpers.get(babelHelpers.getPrototypeOf(Foo.prototype), (_this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this))).method, babelHelpers.assertThisInitialized(_this)).call(_this); return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-2/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-2/output.js index eacbb60486..a38f951718 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-2/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-2/output.js @@ -7,7 +7,7 @@ function (_Bar) { var _this; babelHelpers.classCallCheck(this, Foo); - return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this, babelHelpers.assertThisInitialized(_this))); + return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this, babelHelpers.assertThisInitialized(_this))); } return Foo; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-3/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-3/output.js index ee5d13b48e..753e40bf0a 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-3/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-3/output.js @@ -11,7 +11,7 @@ function (_Bar) { var fn = () => babelHelpers.assertThisInitialized(_this); fn(); - return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); } return Foo; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-4/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-4/output.js index 42144392f3..f012933cec 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-4/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-4/output.js @@ -10,7 +10,7 @@ function (_Bar) { var fn = () => babelHelpers.assertThisInitialized(_this); - _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); fn(); return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes/output.js index b505f250e4..75bd134ebd 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes/output.js @@ -8,7 +8,7 @@ function (_Bar) { babelHelpers.classCallCheck(this, Foo); _this.foo = "bar"; - return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)); + return _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).call(this)); } return Foo; diff --git a/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/regression/4349/output.js b/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/regression/4349/output.js index 95498e45be..232a78272c 100644 --- a/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/regression/4349/output.js +++ b/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/regression/4349/output.js @@ -10,7 +10,7 @@ foo = _obj = { bar() { var _ref; - return _ref = _get(_obj.__proto__ || Object.getPrototypeOf(_obj), "baz", this), _set(_obj.__proto__ || Object.getPrototypeOf(_obj), "baz", Math.pow(_ref, 12), this); + return _ref = _get(_getPrototypeOf(_obj), "baz", this), _set(_getPrototypeOf(_obj), "baz", Math.pow(_ref, 12), this); } }; diff --git a/packages/babel-plugin-transform-function-name/test/fixtures/function-name/modules-3/output.js b/packages/babel-plugin-transform-function-name/test/fixtures/function-name/modules-3/output.js index 6ea22abade..79a6de9fc3 100644 --- a/packages/babel-plugin-transform-function-name/test/fixtures/function-name/modules-3/output.js +++ b/packages/babel-plugin-transform-function-name/test/fixtures/function-name/modules-3/output.js @@ -14,7 +14,7 @@ function (_React$Component) { function Login() { babelHelpers.classCallCheck(this, Login); - return babelHelpers.possibleConstructorReturn(this, (Login.__proto__ || Object.getPrototypeOf(Login)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Login).apply(this, arguments)); } babelHelpers.createClass(Login, [{ diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/object-super/statically-bound/output.js b/packages/babel-plugin-transform-object-super/test/fixtures/object-super/statically-bound/output.js index 7d3611def6..a992284684 100644 --- a/packages/babel-plugin-transform-object-super/test/fixtures/object-super/statically-bound/output.js +++ b/packages/babel-plugin-transform-object-super/test/fixtures/object-super/statically-bound/output.js @@ -2,6 +2,6 @@ var _obj; var o = _obj = { m: function () { - return babelHelpers.get(_obj.__proto__ || Object.getPrototypeOf(_obj), "x", this); + return babelHelpers.get(babelHelpers.getPrototypeOf(_obj), "x", this); } }; diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/object-super/super-exponentiation/output.js b/packages/babel-plugin-transform-object-super/test/fixtures/object-super/super-exponentiation/output.js index 246e28c44f..3d37af8bdf 100644 --- a/packages/babel-plugin-transform-object-super/test/fixtures/object-super/super-exponentiation/output.js +++ b/packages/babel-plugin-transform-object-super/test/fixtures/object-super/super-exponentiation/output.js @@ -10,6 +10,6 @@ foo = _obj = { bar: function () { var _ref; - return _ref = _get(_obj.__proto__ || Object.getPrototypeOf(_obj), "baz", this), _set(_obj.__proto__ || Object.getPrototypeOf(_obj), "baz", _ref ** 12, this); + return _ref = _get(_getPrototypeOf(_obj), "baz", this), _set(_getPrototypeOf(_obj), "baz", _ref ** 12, this); } }; diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/rest-nested-iife/output.js b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/rest-nested-iife/output.js index 0c5007d71a..7975fc6d85 100644 --- a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/rest-nested-iife/output.js +++ b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/rest-nested-iife/output.js @@ -7,7 +7,7 @@ function broken(x) { function Foo() { babelHelpers.classCallCheck(this, Foo); - return babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Foo).apply(this, arguments)); } return Foo; diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/regression/6057-expanded/output.js b/packages/babel-plugin-transform-parameters/test/fixtures/regression/6057-expanded/output.js index 7ddf5ae622..01a7ef308a 100644 --- a/packages/babel-plugin-transform-parameters/test/fixtures/regression/6057-expanded/output.js +++ b/packages/babel-plugin-transform-parameters/test/fixtures/regression/6057-expanded/output.js @@ -21,6 +21,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } +function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); } + 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, enumerable: false, 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); } @@ -33,7 +35,7 @@ function (_Component) { _inherits(App, _Component); function App() { - var _ref; + var _getPrototypeOf2; var _temp, _this; @@ -43,7 +45,7 @@ function (_Component) { args[_key] = arguments[_key]; } - return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = App.__proto__ || Object.getPrototypeOf(App)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "exportType", { + return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(App)).call.apply(_getPrototypeOf2, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "exportType", { configurable: true, enumerable: true, writable: true, diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/optimisation.react.constant-elements/output.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/optimisation.react.constant-elements/output.js index 55beb4d7e3..985568ba1d 100644 --- a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/optimisation.react.constant-elements/output.js +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/optimisation.react.constant-elements/output.js @@ -13,7 +13,7 @@ function (_React$Component) { function App() { babelHelpers.classCallCheck(this, App); - return babelHelpers.possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).apply(this, arguments)); + return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(App).apply(this, arguments)); } babelHelpers.createClass(App, [{ diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useBuiltIns-useESModules/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useBuiltIns-useESModules/output.js index 25dba1a3a6..e6a57dbeb5 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useBuiltIns-useESModules/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useBuiltIns-useESModules/output.js @@ -2,6 +2,8 @@ var _classCallCheck = require("@babel/runtime/helpers/builtin/es6/classCallCheck var _possibleConstructorReturn = require("@babel/runtime/helpers/builtin/es6/possibleConstructorReturn"); +var _getPrototypeOf = require("@babel/runtime/helpers/builtin/es6/getPrototypeOf"); + var _inherits = require("@babel/runtime/helpers/builtin/es6/inherits"); let Foo = @@ -12,7 +14,7 @@ function (_Bar) { function Foo() { _classCallCheck(this, Foo); - return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments)); + return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments)); } return Foo; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useBuiltIns/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useBuiltIns/output.js index 4fde1fa8a8..a9cfc25a85 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useBuiltIns/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useBuiltIns/output.js @@ -2,6 +2,8 @@ var _classCallCheck = require("@babel/runtime/helpers/builtin/classCallCheck"); var _possibleConstructorReturn = require("@babel/runtime/helpers/builtin/possibleConstructorReturn"); +var _getPrototypeOf = require("@babel/runtime/helpers/builtin/getPrototypeOf"); + var _inherits = require("@babel/runtime/helpers/builtin/inherits"); let Foo = @@ -12,7 +14,7 @@ function (_Bar) { function Foo() { _classCallCheck(this, Foo); - return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments)); + return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments)); } return Foo; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules/output.js index f278df2a5c..19375e1d05 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules/output.js @@ -1,9 +1,9 @@ -var _Object$getPrototypeOf = require("@babel/runtime/core-js/object/get-prototype-of"); - var _classCallCheck = require("@babel/runtime/helpers/es6/classCallCheck"); var _possibleConstructorReturn = require("@babel/runtime/helpers/es6/possibleConstructorReturn"); +var _getPrototypeOf = require("@babel/runtime/helpers/es6/getPrototypeOf"); + var _inherits = require("@babel/runtime/helpers/es6/inherits"); let Foo = @@ -14,7 +14,7 @@ function (_Bar) { function Foo() { _classCallCheck(this, Foo); - return _possibleConstructorReturn(this, (Foo.__proto__ || _Object$getPrototypeOf(Foo)).apply(this, arguments)); + return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments)); } return Foo; diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-7527/output.js b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-7527/output.js index aef1b875ce..3fe1fee5cc 100644 --- a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-7527/output.js +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-7527/output.js @@ -26,7 +26,7 @@ function (_Date) { function MyDate(time) { _classCallCheck(this, MyDate); - return _possibleConstructorReturn(this, (MyDate.__proto__ || Object.getPrototypeOf(MyDate)).call(this, time)); + return _possibleConstructorReturn(this, _getPrototypeOf(MyDate).call(this, time)); } return MyDate;