Make how global object is fetched more general.

This commit is contained in:
Brad Nelson
2022-07-12 13:18:01 -07:00
parent 496b7d8c81
commit cd9228a609

View File

@ -271,12 +271,13 @@ var ffi = {
heap[128 + 6] = 256 * 4; // set g_sys.heap = 256 * 4; heap[128 + 6] = 256 * 4; // set g_sys.heap = 256 * 4;
var globalObj; function getGlobalObj() {
if (typeof window === 'undefined') { return (function(g) {
globalObj = global; return g;
} else { })(new Function('return this')());
globalObj = window;
} }
var globalObj = getGlobalObj();
var module = VM(globalObj, ffi, heap); var module = VM(globalObj, ffi, heap);
Init(); Init();
setTimeout(function() { setTimeout(function() {