Skip to content

Commit

Permalink
[Fix] globalThis should be writable
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 7, 2022
1 parent 53afc39 commit 8759985
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module.exports = function shimGlobal() {
var polyfill = getPolyfill();
if (define.supportsDescriptors) {
var descriptor = Object.getOwnPropertyDescriptor(polyfill, 'globalThis');
if (!descriptor || (descriptor.configurable && (descriptor.enumerable || descriptor.writable || globalThis !== polyfill))) { // eslint-disable-line max-len
if (!descriptor || (descriptor.configurable && (descriptor.enumerable || !descriptor.writable || globalThis !== polyfill))) { // eslint-disable-line max-len
Object.defineProperty(polyfill, 'globalThis', {
configurable: true,
enumerable: false,
value: polyfill,
writable: false
writable: true
});
}
} else if (typeof globalThis !== 'object' || globalThis !== polyfill) {
Expand Down
2 changes: 1 addition & 1 deletion test/shimmed.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('shimmed', function (t) {

t.test('writability', { skip: !defineProperties.supportsDescriptors }, function (wt) {
var desc = Object.getOwnPropertyDescriptor(globalThis, 'globalThis');
wt.equal(desc.writable, false, 'globalThis.globalThis is not writable');
wt.equal(desc.writable, true, 'globalThis.globalThis is writable');
wt.end();
});

Expand Down

0 comments on commit 8759985

Please sign in to comment.