@@ -3625,23 +3625,19 @@ void Generator::GenerateFile(const GeneratorOptions& options,
36253625 if (options.import_style == GeneratorOptions::kImportCommonJsStrict ) {
36263626 printer->Print (" var proto = {};\n\n " );
36273627 } else {
3628- // To get the global object we call a function with .call(null), this will set "this" inside the
3629- // function to the global object.
3630- // This does not work if we are running in strict mode ("use strict"),
3631- // so we fallback to the following things (in order from first to last):
3628+ // To get the global object we call a function with .call(null), this will
3629+ // set "this" inside the function to the global object. This does not work
3630+ // if we are running in strict mode ("use strict"), so we fallback to the
3631+ // following things (in order from first to last):
36323632 // - window: defined in browsers
36333633 // - global: defined in most server side environments like NodeJS
36343634 // - self: defined inside Web Workers (WorkerGlobalScope)
3635- // - Function('return this')(): this will work on most platforms, but it may be blocked by things like CSP.
3635+ // - Function('return this')(): this will work on most platforms, but it
3636+ // may be blocked by things like CSP.
36363637 // Function('') is almost the same as eval('')
36373638 printer->Print (
3638- " var global = (function() {\n "
3639- " if (this) { return this; }\n "
3640- " if (typeof window !== 'undefined') { return window; }\n "
3641- " if (typeof global !== 'undefined') { return global; }\n "
3642- " if (typeof self !== 'undefined') { return self; }\n "
3643- " return Function('return this')();\n "
3644- " }.call(null));\n\n " );
3639+ " var global = (function() { return this || window || global || self "
3640+ " || Function('return this')(); }).call(null);\n\n " );
36453641 }
36463642
36473643 for (int i = 0 ; i < file->dependency_count (); i++) {
0 commit comments