From 72fa863fb0f0babef24d9696ae6a203c07622307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 13 Aug 2018 07:33:58 +0200 Subject: [PATCH 1/2] Fix _isNaiveReflectConstruct helper Date#toString is generic in ES2015 [1] and it doesn't throw, but it returns "Invalid Date" [1]: https://github.com/tc39/ecma262/issues/1268#issuecomment-410104832 --- packages/babel-helpers/src/helpers.js | 18 ++++++++++++------ .../test/fixtures/public/foobar/output.js | 2 +- .../test/fixtures/regression/6154/output.js | 2 +- .../fixtures/legacy-regression/7030/output.js | 2 +- .../fixtures/extend-builtins/loose/output.js | 2 +- .../extend-builtins/shadowed/output.js | 2 +- .../fixtures/extend-builtins/spec/output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../fixtures/get-set/memoized-assign/output.js | 2 +- .../fixtures/get-set/memoized-update/output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../test/fixtures/regression/2663/output.js | 2 +- .../test/fixtures/regression/2694/output.js | 2 +- .../test/fixtures/regression/2775/output.js | 2 +- .../test/fixtures/regression/3028/output.js | 2 +- .../test/fixtures/regression/5769/output.js | 2 +- .../test/fixtures/regression/5817/output.js | 2 +- .../test/fixtures/regression/8499/output.js | 2 +- .../test/fixtures/regression/T2494/output.js | 2 +- .../test/fixtures/regression/T2997/output.js | 2 +- .../test/fixtures/regression/T7537/output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../fixtures/function-name/modules-3/output.js | 2 +- .../regression/6057-expanded/output.js | 2 +- .../output.js | 2 +- .../corejs-useES6Modules/output.mjs | 2 +- .../fixtures/use-options/corejs/output.mjs | 2 +- .../useESModules-cjs-auto/output.js | 2 +- .../use-options/useESModules-cjs/output.js | 2 +- .../useESModules-mjs-auto/output.mjs | 2 +- .../use-options/useESModules-mjs/output.mjs | 2 +- .../output.js | 2 +- .../plugins-integration/issue-7527/output.js | 2 +- 47 files changed, 58 insertions(+), 52 deletions(-) diff --git a/packages/babel-helpers/src/helpers.js b/packages/babel-helpers/src/helpers.js index 9eec007db4ca..20bb71ddb286 100644 --- a/packages/babel-helpers/src/helpers.js +++ b/packages/babel-helpers/src/helpers.js @@ -506,10 +506,12 @@ helpers.setPrototypeOf = helper("7.0.0-beta.0")` helpers.isNativeReflectConstruct = helper("7.9.0")` export default function _isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - - // core-js@3 - if (Reflect.construct.sham) return false; + if ( + typeof Reflect === "undefined" || + !Reflect.construct || + // core-js@3 + Reflect.construct.sham + ) return false; // Proxy can't be polyfilled. Every browser implemented // proxies before or at the same time as Reflect.construct, @@ -523,8 +525,12 @@ helpers.isNativeReflectConstruct = helper("7.9.0")` try { // If the internal slots aren't set, this throws an error similar to // TypeError: this is not a Date object. - Date.prototype.toString.call(Reflect.construct(Date, [], function() {})); - return true; + // Date#toString is generic in ES2015 [1] and it doesn't throw, but it + // returns "Invalid Date" if the receiver is not a properly initialized + // Date object. + // [1]: https://github.com/tc39/ecma262/issues/1268#issuecomment-410104832 + + return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})) !== "Invalid Date"; } catch (e) { return false; } 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 8692e792ecac..34926d197ade 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var Child = /*#__PURE__*/function (_Parent) { "use strict"; 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 d0fbcc222e79..7de89cc88f59 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 @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } 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); } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js index 994b2fed0943..4e3eb0600b37 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js @@ -12,7 +12,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/loose/output.js b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/loose/output.js index bbdc4b88e55f..1f6cc7e0b5bd 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/loose/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/loose/output.js @@ -4,7 +4,7 @@ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } 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 08d6762c3853..ccc0bb6a5258 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } let Array = function Array() { "use strict"; 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 f0bfc98c7009..6b7dacff1982 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 @@ -12,7 +12,7 @@ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js index c353ead3296f..6fba6f08ce08 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js index 913687bd371a..456c2133e5b9 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js index cac6975c65f6..6e4f3f6d621a 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js index 761aa2ce1a3f..9e83cfba2ab7 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js index ca90f6a3496e..966e1847acc1 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js index afcf95a7c4a4..d86fb7b71c11 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js index 108e53685565..ff9962f6da23 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js index b53c2a6f78a2..53ecc135c267 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js index 9ec9d0395d5a..a5636697fce7 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js @@ -24,7 +24,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js index ef62b457c072..045952f01de6 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js @@ -24,7 +24,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js index 76b9296e4db1..769d3b94eb1c 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js index f4223eed6f5c..06ddfa455ce1 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js index b075865b1941..372f949f34d2 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js index 92ca047d04ed..14d0d5bd92e7 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js index fe67657aad68..b2beb69176bf 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js index febacce3ceb7..8c769c30add8 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js index 409d32af0144..7a8fe7d5300f 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 7a22ac1d09dc..1cdf98de4db5 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 @@ -13,7 +13,7 @@ var _binarySerializer = babelHelpers.interopRequireDefault(require("./helpers/bi function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } // import ... var Connection = /*#__PURE__*/function (_EventEmitter) { 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 57955f62dba7..02248de6f774 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 @@ -9,7 +9,7 @@ var _BaseFoo2 = babelHelpers.interopRequireDefault(require("./BaseFoo")); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var SubFoo = /*#__PURE__*/function (_BaseFoo) { babelHelpers.inherits(SubFoo, _BaseFoo); 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 452a1314fb6b..eda186555a54 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 @@ -9,7 +9,7 @@ var _react = babelHelpers.interopRequireDefault(require("react")); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var RandomComponent = /*#__PURE__*/function (_Component) { babelHelpers.inherits(RandomComponent, _Component); 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 32aa05f9ff15..7d4ff62261ae 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 @@ -7,7 +7,7 @@ exports["default"] = void 0; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var b = function b() { babelHelpers.classCallCheck(this, b); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js index 1a3f9f255584..62de762d5528 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var Point = /*#__PURE__*/function () { "use strict"; 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 f28e09757b71..5f7d857445f6 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var A = /*#__PURE__*/function (_B) { "use strict"; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js index da19e68dcd3d..1880e27b023a 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var oldReflect = this.Reflect; var oldHTMLElement = this.HTMLElement; 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 e88e52a46094..24a0ba5c9c12 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var x = { Foo: /*#__PURE__*/function (_Foo) { 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 daaf869676e9..19d25ad42455 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var A = function A() { "use strict"; 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 33a02fc89478..ff9114402d23 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 @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 331a91b99e03..9e3a068ab38f 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 @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } 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); } 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 c91950896244..e3828ee1fbb3 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 @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } 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); } 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 1c4bd028204f..d3ac6985e5c5 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 @@ -9,7 +9,7 @@ var _store = require("./store"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } let Login = /*#__PURE__*/function (_React$Component) { babelHelpers.inherits(Login, _React$Component); 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 5fedbe5fe4c2..7123f06d1225 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 @@ -27,7 +27,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 a9b90e8bc5d0..1c82ef19de8b 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } var _ref =
diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useES6Modules/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useES6Modules/output.mjs index ce15b2059cbd..ec831575bdda 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useES6Modules/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useES6Modules/output.mjs @@ -6,7 +6,7 @@ import _getPrototypeOf from "@babel/runtime-corejs2/helpers/esm/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(_Reflect$construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct || _Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(_Reflect$construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs/output.mjs index ccbb71ba8094..eaf92e39dde9 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs/output.mjs @@ -6,7 +6,7 @@ import _getPrototypeOf from "@babel/runtime-corejs2/helpers/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(_Reflect$construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct || _Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(_Reflect$construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js index 44a2829d88f5..87c4836b0375 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js @@ -8,7 +8,7 @@ var _getPrototypeOf = require("@babel/runtime/helpers/getPrototypeOf"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { "use strict"; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js index 44a2829d88f5..87c4836b0375 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js @@ -8,7 +8,7 @@ var _getPrototypeOf = require("@babel/runtime/helpers/getPrototypeOf"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { "use strict"; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs index ff58e79eb461..fcb0ea34a11a 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs @@ -5,7 +5,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs index ff58e79eb461..fcb0ea34a11a 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs @@ -5,7 +5,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js index 900eceb21acf..6f857b4be734 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 0ee57e30fdd3..313703fe541e 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 @@ -16,7 +16,7 @@ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } From cc85d4e428da65085bcf12d1cb803391de379a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 22 Feb 2021 22:30:05 +0100 Subject: [PATCH 2/2] Justin's review --- packages/babel-helpers/src/helpers.js | 19 +++++++------------ .../test/fixtures/public/foobar/output.js | 2 +- .../test/fixtures/regression/6154/output.js | 2 +- .../fixtures/legacy-regression/7030/output.js | 2 +- .../fixtures/extend-builtins/loose/output.js | 2 +- .../extend-builtins/shadowed/output.js | 2 +- .../fixtures/extend-builtins/spec/output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../get-set/memoized-assign/output.js | 2 +- .../get-set/memoized-update/output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../test/fixtures/regression/2663/output.js | 2 +- .../test/fixtures/regression/2694/output.js | 2 +- .../test/fixtures/regression/2775/output.js | 2 +- .../test/fixtures/regression/3028/output.js | 2 +- .../test/fixtures/regression/5769/output.js | 2 +- .../test/fixtures/regression/5817/output.js | 2 +- .../test/fixtures/regression/8499/output.js | 2 +- .../test/fixtures/regression/T2494/output.js | 2 +- .../test/fixtures/regression/T2997/output.js | 2 +- .../test/fixtures/regression/T7537/output.js | 2 +- .../output.js | 2 +- .../output.js | 2 +- .../function-name/modules-3/output.js | 2 +- .../regression/6057-expanded/output.js | 2 +- .../output.js | 2 +- .../corejs-useES6Modules/output.mjs | 2 +- .../fixtures/use-options/corejs/output.mjs | 2 +- .../useESModules-cjs-auto/output.js | 2 +- .../use-options/useESModules-cjs/output.js | 2 +- .../useESModules-mjs-auto/output.mjs | 2 +- .../use-options/useESModules-mjs/output.mjs | 2 +- .../output.js | 2 +- .../plugins-integration/issue-7527/output.js | 2 +- 47 files changed, 53 insertions(+), 58 deletions(-) diff --git a/packages/babel-helpers/src/helpers.js b/packages/babel-helpers/src/helpers.js index 20bb71ddb286..f0d1a88592f7 100644 --- a/packages/babel-helpers/src/helpers.js +++ b/packages/babel-helpers/src/helpers.js @@ -506,12 +506,10 @@ helpers.setPrototypeOf = helper("7.0.0-beta.0")` helpers.isNativeReflectConstruct = helper("7.9.0")` export default function _isNativeReflectConstruct() { - if ( - typeof Reflect === "undefined" || - !Reflect.construct || - // core-js@3 - Reflect.construct.sham - ) return false; + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + + // core-js@3 + if (Reflect.construct.sham) return false; // Proxy can't be polyfilled. Every browser implemented // proxies before or at the same time as Reflect.construct, @@ -524,13 +522,10 @@ helpers.isNativeReflectConstruct = helper("7.9.0")` // use our fallback implementation. try { // If the internal slots aren't set, this throws an error similar to - // TypeError: this is not a Date object. - // Date#toString is generic in ES2015 [1] and it doesn't throw, but it - // returns "Invalid Date" if the receiver is not a properly initialized - // Date object. - // [1]: https://github.com/tc39/ecma262/issues/1268#issuecomment-410104832 + // TypeError: this is not a Boolean object. - return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})) !== "Invalid Date"; + Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); + return true; } catch (e) { return false; } 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 34926d197ade..24455bd66a3e 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var Child = /*#__PURE__*/function (_Parent) { "use strict"; 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 7de89cc88f59..f833d3491aa1 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 @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 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); } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js index 4e3eb0600b37..2cfd6bb72ca9 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js @@ -12,7 +12,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/loose/output.js b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/loose/output.js index 1f6cc7e0b5bd..6656de561998 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/loose/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/loose/output.js @@ -4,7 +4,7 @@ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } 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 ccc0bb6a5258..4279f63b0606 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } let Array = function Array() { "use strict"; 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 6b7dacff1982..52f199090ef2 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 @@ -12,7 +12,7 @@ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js index 6fba6f08ce08..68b519765dd2 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js index 456c2133e5b9..09274afc5a9b 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js index 6e4f3f6d621a..7cd583c6783d 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js index 9e83cfba2ab7..0f52c66847c0 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js index 966e1847acc1..7e3d8cc4b0b3 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js index d86fb7b71c11..d16793fb2dbc 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js index ff9962f6da23..678e20f4109c 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js index 53ecc135c267..9614013afbf3 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js @@ -14,7 +14,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js index a5636697fce7..151c25d42e27 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js @@ -24,7 +24,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js index 045952f01de6..df734f46353a 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js @@ -24,7 +24,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js index 769d3b94eb1c..aed4c0ef7278 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js index 06ddfa455ce1..53c3c81d6b6e 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js index 372f949f34d2..bba625433cea 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js index 14d0d5bd92e7..0b3aba6cf6c4 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js index b2beb69176bf..369e244bc85f 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js index 8c769c30add8..e78cf98d9f90 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js @@ -22,7 +22,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js index 7a8fe7d5300f..5825fb560aa9 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js @@ -18,7 +18,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 1cdf98de4db5..8d76080f69fa 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 @@ -13,7 +13,7 @@ var _binarySerializer = babelHelpers.interopRequireDefault(require("./helpers/bi function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } // import ... var Connection = /*#__PURE__*/function (_EventEmitter) { 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 02248de6f774..5618071963e7 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 @@ -9,7 +9,7 @@ var _BaseFoo2 = babelHelpers.interopRequireDefault(require("./BaseFoo")); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var SubFoo = /*#__PURE__*/function (_BaseFoo) { babelHelpers.inherits(SubFoo, _BaseFoo); 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 eda186555a54..99084570cf07 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 @@ -9,7 +9,7 @@ var _react = babelHelpers.interopRequireDefault(require("react")); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var RandomComponent = /*#__PURE__*/function (_Component) { babelHelpers.inherits(RandomComponent, _Component); 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 7d4ff62261ae..f9ecd2cc6162 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 @@ -7,7 +7,7 @@ exports["default"] = void 0; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var b = function b() { babelHelpers.classCallCheck(this, b); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js index 62de762d5528..ce66d339a0ac 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var Point = /*#__PURE__*/function () { "use strict"; 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 5f7d857445f6..3130341c6fdc 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var A = /*#__PURE__*/function (_B) { "use strict"; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js index 1880e27b023a..a411679a5c76 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var oldReflect = this.Reflect; var oldHTMLElement = this.HTMLElement; 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 24a0ba5c9c12..d40d6600523d 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var x = { Foo: /*#__PURE__*/function (_Foo) { 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 19d25ad42455..bbfba7c7a58c 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var A = function A() { "use strict"; 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 ff9114402d23..41fd311829a8 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 @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 9e3a068ab38f..a357563467e4 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 @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 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); } 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 e3828ee1fbb3..06aac66c1733 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 @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 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); } 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 d3ac6985e5c5..36cdd3e45c9a 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 @@ -9,7 +9,7 @@ var _store = require("./store"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } let Login = /*#__PURE__*/function (_React$Component) { babelHelpers.inherits(Login, _React$Component); 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 7123f06d1225..f847bbdd657c 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 @@ -27,7 +27,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 1c82ef19de8b..bd906ac46f4c 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 @@ -1,6 +1,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var _ref =
diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useES6Modules/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useES6Modules/output.mjs index ec831575bdda..956a6c2c01e7 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useES6Modules/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useES6Modules/output.mjs @@ -6,7 +6,7 @@ import _getPrototypeOf from "@babel/runtime-corejs2/helpers/esm/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct || _Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(_Reflect$construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs/output.mjs index eaf92e39dde9..7c48dce56391 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs/output.mjs @@ -6,7 +6,7 @@ import _getPrototypeOf from "@babel/runtime-corejs2/helpers/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct || _Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(_Reflect$construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js index 87c4836b0375..170ab3aff935 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js @@ -8,7 +8,7 @@ var _getPrototypeOf = require("@babel/runtime/helpers/getPrototypeOf"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { "use strict"; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js index 87c4836b0375..170ab3aff935 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js @@ -8,7 +8,7 @@ var _getPrototypeOf = require("@babel/runtime/helpers/getPrototypeOf"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { "use strict"; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs index fcb0ea34a11a..573573eeed72 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs @@ -5,7 +5,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs index fcb0ea34a11a..573573eeed72 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs @@ -5,7 +5,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js index 6f857b4be734..1834d5d8842b 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js @@ -10,7 +10,7 @@ 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 313703fe541e..1f31f4595d8a 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 @@ -16,7 +16,7 @@ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct || Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})) !== "Invalid Date"; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }