Uncaught ReferenceError: global is not defined #1911
This commit is contained in:
Родитель
06c14692f4
Коммит
308c4dc13a
|
@ -21,26 +21,29 @@ let _cachedGlobal: Window = null;
|
||||||
* of the properties or functions.
|
* of the properties or functions.
|
||||||
*/
|
*/
|
||||||
export function getGlobal(useCached: boolean = true): Window {
|
export function getGlobal(useCached: boolean = true): Window {
|
||||||
if (!_cachedGlobal || !useCached) {
|
let result = useCached === false ? null : _cachedGlobal;
|
||||||
|
|
||||||
if (typeof globalThis !== strShimUndefined && globalThis) {
|
if (!result) {
|
||||||
_cachedGlobal = globalThis;
|
if (typeof globalThis !== strShimUndefined) {
|
||||||
|
result = globalThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof self !== strShimUndefined && self) {
|
if (!result && typeof self !== strShimUndefined) {
|
||||||
_cachedGlobal = self;
|
result = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window !== strShimUndefined && window) {
|
if (!result && typeof window !== strShimUndefined) {
|
||||||
_cachedGlobal = window;
|
result = window;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result && typeof global !== strShimUndefined) {
|
||||||
|
result = global;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof global !== strShimUndefined && global) {
|
_cachedGlobal = result;
|
||||||
_cachedGlobal = global;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return _cachedGlobal;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function throwTypeError(message: string): never {
|
export function throwTypeError(message: string): never {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче