@@ -3625,23 +3625,19 @@ void Generator::GenerateFile(const GeneratorOptions& options,
3625
3625
if (options.import_style == GeneratorOptions::kImportCommonJsStrict ) {
3626
3626
printer->Print (" var proto = {};\n\n " );
3627
3627
} 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):
3632
3632
// - window: defined in browsers
3633
3633
// - global: defined in most server side environments like NodeJS
3634
3634
// - 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.
3636
3637
// Function('') is almost the same as eval('')
3637
3638
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 " );
3645
3641
}
3646
3642
3647
3643
for (int i = 0 ; i < file->dependency_count (); i++) {
0 commit comments