diff --git a/packages/regenerator-runtime/runtime-module.js b/packages/regenerator-runtime/runtime-module.js index 8e7e2e4c1..57b655799 100644 --- a/packages/regenerator-runtime/runtime-module.js +++ b/packages/regenerator-runtime/runtime-module.js @@ -1,9 +1,6 @@ // This method of obtaining a reference to the global object needs to be // kept identical to the way it is obtained in runtime.js -var g = - typeof global === "object" ? global : - typeof window === "object" ? window : - typeof self === "object" ? self : this; +var g = (function() { return this })() || Function("return this")(); // Use `getOwnPropertyNames` because not all browsers support calling // `hasOwnProperty` on the global `self` object in a worker. See #183. diff --git a/packages/regenerator-runtime/runtime.js b/packages/regenerator-runtime/runtime.js index 5b08c4d34..6f26b1590 100644 --- a/packages/regenerator-runtime/runtime.js +++ b/packages/regenerator-runtime/runtime.js @@ -727,10 +727,8 @@ } }; })( - // Among the various tricks for obtaining a reference to the global - // object, this seems to be the most reliable technique that does not - // use indirect eval (which violates Content Security Policy). - typeof global === "object" ? global : - typeof window === "object" ? window : - typeof self === "object" ? self : this + // In sloppy mode, unbound `this` refers to the global object, fallback to + // Function constructor if we're in global strict mode. That is sadly a form + // of indirect eval which violates Content Security Policy. + (function() { return this })() || Function("return this")() );