mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-26 19:47:20 +00:00
Polyfill is not needed, only globalCheck (#7492)
This commit is contained in:
parent
74e0619782
commit
90f0ff8067
28
boot/boot.js
28
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 : "",
|
||||
|
Loading…
Reference in New Issue
Block a user