diff --git a/boot/boot.js b/boot/boot.js index d06ddb649..a9fb91b74 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -569,26 +569,17 @@ $tw.utils.getTypeEncoding = function(ext) { return typeInfo ? typeInfo.encoding : "utf8"; }; -var polyfill =[ - "// this polyfills the globalThis variable", - "// using the this variable on a getter ", - "// inserted into the prototype of globalThis", - "(function() {", - " if (typeof globalThis === 'object') return;", - " // node.green says this is available since 0.10.48", - " Object.prototype.__defineGetter__('__temp__', function() {", - " return this;", - " });", - " __temp__.globalThis = __temp__;", - " delete Object.prototype.__temp__;", - "}());" -].join("\n"); - var globalCheck =[ - " if(Object.keys(globalThis).length){", - " console.log(Object.keys(globalThis));", + " Object.defineProperty(Object.prototype, '__temp__', {", + " get: function () { return this; },", + " configurable: true", + " });", + " if(Object.keys(__temp__).length){", + " console.log(Object.keys(__temp__));", + " delete Object.prototype.__temp__;", " throw \"Global assignment is not allowed within modules on node.\";", - " }" + " }", + " delete Object.prototype.__temp__;", ].join('\n'); /* @@ -604,7 +595,6 @@ $tw.utils.evalGlobal = function(code,context,filename,sandbox,allowGlobals) { }); // Add the code prologue and epilogue code = [ - (!$tw.browser ? polyfill : ""), "(function(" + contextNames.join(",") + ") {", " (function(){\n" + code + "\n;})();", (!$tw.browser && sandbox && !allowGlobals) ? globalCheck : "",