Comparing version 1.1.0 to 1.1.1
@@ -5,2 +5,9 @@ # Changelog | ||
### [1.1.1](https://github.com/medikoo/ext/compare/v1.1.0...v1.1.1) (2019-10-29) | ||
### Bug Fixes | ||
- Provide naive fallback for sealed Object.prototype case ([a8d528b](https://github.com/medikoo/ext/commit/a8d528b)) | ||
- Workaournd Safari incompatibility case ([0b051e6](https://github.com/medikoo/ext/commit/0b051e6)) | ||
## [1.1.0](https://github.com/medikoo/ext/compare/v1.0.3...v1.1.0) (2019-10-21) | ||
@@ -7,0 +14,0 @@ |
@@ -0,5 +1,11 @@ | ||
var naiveFallback = function () { | ||
if (typeof self === "object" && self) return self; | ||
if (typeof window === "object" && window) return window; | ||
throw new Error("Unable to resolve global `this`"); | ||
}; | ||
module.exports = (function () { | ||
if (this) return this; | ||
// Unexpected strict mode (may happen if e.g. bundled into ESM module), be nice | ||
// Unexpected strict mode (may happen if e.g. bundled into ESM module) | ||
@@ -9,8 +15,18 @@ // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis | ||
// (if you approached one that doesn't please report) | ||
Object.defineProperty(Object.prototype, "__global__", { | ||
get: function () { return this; }, | ||
configurable: true | ||
}); | ||
try { return __global__; } | ||
finally { delete Object.prototype.__global__; } | ||
try { | ||
Object.defineProperty(Object.prototype, "__global__", { | ||
get: function () { return this; }, | ||
configurable: true | ||
}); | ||
} catch (error) { | ||
// Unfortunate case of Object.prototype being sealed (via preventExtensions, seal or freeze) | ||
return naiveFallback(); | ||
} | ||
try { | ||
// Safari case (window.__global__ is resolved with global context, but __global__ does not) | ||
if (!__global__) return naiveFallback(); | ||
return __global__; | ||
} finally { | ||
delete Object.prototype.__global__; | ||
} | ||
})(); |
{ | ||
"name": "ext", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "JavaScript utilities with respect to emerging standard", | ||
@@ -32,3 +32,3 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.5.1", | ||
"eslint": "^6.6.0", | ||
"eslint-config-medikoo": "^2.6.0", | ||
@@ -65,3 +65,5 @@ "git-list-updated": "^1.2.1", | ||
"globals": { | ||
"__global__": true | ||
"__global__": true, | ||
"self": true, | ||
"window": true | ||
}, | ||
@@ -68,0 +70,0 @@ "rules": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14578
221