mirror of
https://github.com/denoland/deno.git
synced 2025-01-10 16:11:13 -05:00
Adjust console constructor (#2649)
https://github.com/denoland/deno/pull/2073#discussion_r303401539
This commit is contained in:
parent
4e248ecda9
commit
181cfc9fb5
2 changed files with 9 additions and 9 deletions
|
@ -502,6 +502,14 @@ export class Console {
|
||||||
this.indentLevel = 0;
|
this.indentLevel = 0;
|
||||||
this.collapsedAt = null;
|
this.collapsedAt = null;
|
||||||
this[isConsoleInstance] = true;
|
this[isConsoleInstance] = true;
|
||||||
|
|
||||||
|
// ref https://console.spec.whatwg.org/#console-namespace
|
||||||
|
// For historical web-compatibility reasons, the namespace object for
|
||||||
|
// console must have as its [[Prototype]] an empty object, created as if
|
||||||
|
// by ObjectCreate(%ObjectPrototype%), instead of %ObjectPrototype%.
|
||||||
|
let console = Object.create({}) as Console;
|
||||||
|
Object.assign(console, this);
|
||||||
|
return console;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes the arguments to stdout */
|
/** Writes the arguments to stdout */
|
||||||
|
|
|
@ -51,21 +51,13 @@ window.window = window;
|
||||||
immutableDefine(window, "Deno", deno);
|
immutableDefine(window, "Deno", deno);
|
||||||
Object.freeze(window.Deno);
|
Object.freeze(window.Deno);
|
||||||
|
|
||||||
// ref https://console.spec.whatwg.org/#console-namespace
|
|
||||||
// For historical web-compatibility reasons, the namespace object for
|
|
||||||
// console must have as its [[Prototype]] an empty object, created as if
|
|
||||||
// by ObjectCreate(%ObjectPrototype%), instead of %ObjectPrototype%.
|
|
||||||
let console = Object.create({}) as consoleTypes.Console;
|
|
||||||
Object.assign(console, new consoleTypes.Console(core.print));
|
|
||||||
console[consoleTypes.isConsoleInstance] = true;
|
|
||||||
|
|
||||||
// Globally available functions and object instances.
|
// Globally available functions and object instances.
|
||||||
window.atob = textEncoding.atob;
|
window.atob = textEncoding.atob;
|
||||||
window.btoa = textEncoding.btoa;
|
window.btoa = textEncoding.btoa;
|
||||||
window.fetch = fetchTypes.fetch;
|
window.fetch = fetchTypes.fetch;
|
||||||
window.clearTimeout = timers.clearTimeout;
|
window.clearTimeout = timers.clearTimeout;
|
||||||
window.clearInterval = timers.clearInterval;
|
window.clearInterval = timers.clearInterval;
|
||||||
window.console = console;
|
window.console = new consoleTypes.Console(core.print);
|
||||||
window.setTimeout = timers.setTimeout;
|
window.setTimeout = timers.setTimeout;
|
||||||
window.setInterval = timers.setInterval;
|
window.setInterval = timers.setInterval;
|
||||||
window.location = (undefined as unknown) as domTypes.Location;
|
window.location = (undefined as unknown) as domTypes.Location;
|
||||||
|
|
Loading…
Reference in a new issue