File tree Expand file tree Collapse file tree 1 file changed +2
-0
lines changed Expand file tree Collapse file tree 1 file changed +2
-0
lines changed Original file line number Diff line number Diff line change @@ -3630,6 +3630,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
36303630 // set "this" inside the function to the global object. This does not work
36313631 // if we are running in strict mode ("use strict"), so we fallback to the
36323632 // following things (in order from first to last):
3633+ // - globalThis: defined in browsers
36333634 // - window: defined in browsers
36343635 // - global: defined in most server side environments like NodeJS
36353636 // - self: defined inside Web Workers (WorkerGlobalScope)
@@ -3639,6 +3640,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
36393640 printer->Print (
36403641 " var global = (function() {\n "
36413642 " if (this) { return this; }\n "
3643+ " if (typeof globalThis !== 'undefined') { return globalThis; }\n "
36423644 " if (typeof window !== 'undefined') { return window; }\n "
36433645 " if (typeof global !== 'undefined') { return global; }\n "
36443646 " if (typeof self !== 'undefined') { return self; }\n "
You can’t perform that action at this time.
0 commit comments