mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
6d1170f06c
Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: ricky <ricky.miller@gmail.com> Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com> Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> Co-authored-by: legobt <6wbvkn0j@anonaddy.me> Co-authored-by: Pedro Figueiredo <pedro.figueiredo@consensys.net>
49 lines
1.8 KiB
Diff
49 lines
1.8 KiB
Diff
diff --git a/helpers/construct.js b/helpers/construct.js
|
|
index ecc013db4703c1c6ca8a5bba3db3955e75c1a972..08826bea9453f1351c08d44be9fffca92923fd76 100644
|
|
--- a/helpers/construct.js
|
|
+++ b/helpers/construct.js
|
|
@@ -1,22 +1,21 @@
|
|
-var setPrototypeOf = require("./setPrototypeOf.js");
|
|
+// All of MetaMask's supported browsers include `Reflect.construct` support, so
|
|
+// we don't need this polyfill.
|
|
|
|
-var isNativeReflectConstruct = require("./isNativeReflectConstruct.js");
|
|
+// This Proxy preseves the two properties that were added by `@babel/runtime`.
|
|
+// I am not entire sure what these properties are for (maybe ES5/ES6
|
|
+// interoperability?) but they have been preserved just in case.
|
|
+const reflectProxy = new Proxy(
|
|
+ Reflect.construct,
|
|
+ {
|
|
+ get: function (target, property) {
|
|
+ if (property === 'default') {
|
|
+ return target;
|
|
+ } else if (property === '__esModule') {
|
|
+ return true;
|
|
+ }
|
|
+ return Reflect.get(...arguments);
|
|
+ }
|
|
+ }
|
|
+);
|
|
|
|
-function _construct(Parent, args, Class) {
|
|
- if (isNativeReflectConstruct()) {
|
|
- module.exports = _construct = Reflect.construct.bind(), module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
- } else {
|
|
- module.exports = _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;
|
|
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
- }
|
|
-
|
|
- return _construct.apply(null, arguments);
|
|
-}
|
|
-
|
|
-module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
\ No newline at end of file
|
|
+module.exports = reflectProxy;
|
|
\ No newline at end of file
|