diff --git a/package.json b/package.json index dffe898..6858534 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "shim" ], "dependencies": { - "define-properties": "^1.2.1" + "define-properties": "^1.2.1", + "gopd": "^1.0.1" }, "devDependencies": { "@es-shims/api": "^2.5.0", diff --git a/shim.js b/shim.js index 7ccf455..ee89bbb 100644 --- a/shim.js +++ b/shim.js @@ -1,13 +1,20 @@ 'use strict'; var define = require('define-properties'); +var gOPD = require('gopd'); var getPolyfill = require('./polyfill'); 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 + var descriptor = gOPD(polyfill, 'globalThis'); + if ( + !descriptor + || ( + descriptor.configurable + && (descriptor.enumerable || !descriptor.writable || globalThis !== polyfill) + ) + ) { Object.defineProperty(polyfill, 'globalThis', { configurable: true, enumerable: false,