window -> globalThis
This commit is contained in:
parent
43b803dd86
commit
6b5f984299
@ -5,7 +5,7 @@ export class CodeRunner {
|
||||
this.isRunning = false;
|
||||
this.evalScope = {};
|
||||
|
||||
window.playgroundConsole = this.console;
|
||||
globalThis.playgroundConsole = this.console;
|
||||
}
|
||||
|
||||
setCode(code) {
|
||||
@ -48,13 +48,13 @@ export class CodeRunner {
|
||||
}
|
||||
|
||||
evaluateCode(code) {
|
||||
// Move evalScope to window
|
||||
const oldWindow = {};
|
||||
// Move evalScope to globalThis
|
||||
const oldGlobalThis = {};
|
||||
for (const prop in this.evalScope) {
|
||||
if (!this.evalScope.hasOwnProperty(prop)) continue;
|
||||
if (!Object.hasOwn(this.evalScope, prop)) continue;
|
||||
|
||||
oldWindow[prop] = window[prop];
|
||||
window[prop] = this.evalScope[prop];
|
||||
oldGlobalThis[prop] = globalThis[prop];
|
||||
globalThis[prop] = this.evalScope[prop];
|
||||
}
|
||||
|
||||
// Evaluate code
|
||||
@ -75,10 +75,10 @@ export class CodeRunner {
|
||||
}
|
||||
|
||||
// Restore old window props
|
||||
for (const prop in oldWindow) {
|
||||
if (!oldWindow.hasOwnProperty(prop)) continue;
|
||||
for (const prop in oldGlobalThis) {
|
||||
if (!Object.hasOwn(globalThis, prop)) continue;
|
||||
|
||||
window[prop] = oldWindow[prop];
|
||||
globalThis[prop] = oldGlobalThis[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export class Gesundheit {
|
||||
};
|
||||
|
||||
const assetStore = transaction.objectStore("asset");
|
||||
const req = assetStore.add({
|
||||
const _req = assetStore.add({
|
||||
name: "idk",
|
||||
mime: "idk",
|
||||
bytes: [],
|
||||
|
@ -3,7 +3,7 @@ export class PlaygroundConsole {
|
||||
this.elem = elem;
|
||||
|
||||
// Used within error stack traces
|
||||
window.gotoLine = (line, col) => {
|
||||
globalThis.gotoLine = (line, col) => {
|
||||
editor.gotoLine(line, col, true);
|
||||
editor.focus();
|
||||
};
|
||||
@ -11,7 +11,7 @@ export class PlaygroundConsole {
|
||||
|
||||
#formatStacktrace(stack) {
|
||||
return stack
|
||||
.replaceAll(window.origin + "/", "")
|
||||
.replaceAll(globalThis.origin + "/", "")
|
||||
.replace(
|
||||
/data:text\/javascript;charset=utf-8,[^:]+:(\d+):(\d+)/g,
|
||||
"<a href='javascript:gotoLine($1,$2)'>karlkoder-playground:$1:$2</a>",
|
||||
@ -30,7 +30,7 @@ export class PlaygroundConsole {
|
||||
return typeof arg;
|
||||
}
|
||||
|
||||
#addKeyValue(entryType, parent, property, arg) {
|
||||
#addKeyValue(_entryType, parent, property, arg) {
|
||||
if (property) {
|
||||
const keyEl = document.createElement("span");
|
||||
keyEl.className = property === "__proto__" ? "prototype" : "property";
|
||||
@ -71,7 +71,7 @@ export class PlaygroundConsole {
|
||||
} else {
|
||||
// Add object properties
|
||||
for (const prop in arg) {
|
||||
if (!arg.hasOwnProperty(prop)) continue;
|
||||
if (!Object.hasOwn(arg, prop)) continue;
|
||||
|
||||
this.#addEntry(
|
||||
entryType,
|
||||
|
@ -53,6 +53,7 @@ const KEYWORDS = [
|
||||
"sessionStorage",
|
||||
"undefined",
|
||||
"window",
|
||||
"globalThis",
|
||||
];
|
||||
|
||||
export class TextCompleter {
|
||||
|
Loading…
x
Reference in New Issue
Block a user