main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
715 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var define = require('define-properties');
|
---|
4 | var gOPD = require('gopd');
|
---|
5 | var getPolyfill = require('./polyfill');
|
---|
6 |
|
---|
7 | module.exports = function shimGlobal() {
|
---|
8 | var polyfill = getPolyfill();
|
---|
9 | if (define.supportsDescriptors) {
|
---|
10 | var descriptor = gOPD(polyfill, 'globalThis');
|
---|
11 | if (
|
---|
12 | !descriptor
|
---|
13 | || (
|
---|
14 | descriptor.configurable
|
---|
15 | && (descriptor.enumerable || !descriptor.writable || globalThis !== polyfill)
|
---|
16 | )
|
---|
17 | ) {
|
---|
18 | Object.defineProperty(polyfill, 'globalThis', {
|
---|
19 | configurable: true,
|
---|
20 | enumerable: false,
|
---|
21 | value: polyfill,
|
---|
22 | writable: true
|
---|
23 | });
|
---|
24 | }
|
---|
25 | } else if (typeof globalThis !== 'object' || globalThis !== polyfill) {
|
---|
26 | polyfill.globalThis = polyfill;
|
---|
27 | }
|
---|
28 | return polyfill;
|
---|
29 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.