workaround toString() quirks on global context (#5198)

closes #5197
This commit is contained in:
Alex Lam S.L
2021-11-27 15:17:51 +00:00
committed by GitHub
parent 1b4bd7082b
commit 12227ebbb0
2 changed files with 22 additions and 7 deletions

View File

@@ -202,13 +202,11 @@ function setup(global, builtins, setup_log, setup_tty) {
});
Object.defineProperties(global, props);
// for Node.js v8+
if (global.toString !== Object.prototype.toString) {
global.__proto__ = Object.defineProperty(Object.create(global.__proto__), "toString", {
value: function() {
return "[object global]";
},
});
}
global.__proto__ = Object.defineProperty(Object.create(global.__proto__), "toString", {
value: function() {
return "[object global]";
},
});
function self() {
return this;