mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-28 23:06:37 +01:00
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
|