diff options
Diffstat (limited to 'packages/taler-wallet-webextension')
-rw-r--r-- | packages/taler-wallet-webextension/src/compat.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/taler-wallet-webextension/src/compat.ts b/packages/taler-wallet-webextension/src/compat.ts index 4635abd80..36846e615 100644 --- a/packages/taler-wallet-webextension/src/compat.ts +++ b/packages/taler-wallet-webextension/src/compat.ts @@ -19,6 +19,21 @@ * WebExtension APIs consistently. */ +// globalThis polyfill, see https://mathiasbynens.be/notes/globalthis +(function () { + if (typeof globalThis === "object") return; + Object.defineProperty(Object.prototype, "__magic__", { + get: function () { + return this; + }, + configurable: true, // This makes it possible to `delete` the getter later. + }); + // @ts-ignore: polyfill magic + __magic__.globalThis = __magic__; // lolwat + // @ts-ignore: polyfill magic + delete Object.prototype.__magic__; +})(); + export function isFirefox(): boolean { const rt = chrome.runtime as any; if (typeof rt.getBrowserInfo === "function") { |