summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
author迷渡 <justjavac@gmail.com>2019-07-17 21:42:04 +0800
committerRyan Dahl <ry@tinyclouds.org>2019-07-17 09:42:04 -0400
commit181cfc9fb5bd2cbb7cd0a994a845e1901d256770 (patch)
tree1793958bd356c8384037e2d5d8bcb2f5ed6af04d /js
parent4e248ecda9bb31478c6db7f5e76fa12b64b516a9 (diff)
Adjust console constructor (#2649)
https://github.com/denoland/deno/pull/2073#discussion_r303401539
Diffstat (limited to 'js')
-rw-r--r--js/console.ts8
-rw-r--r--js/globals.ts10
2 files changed, 9 insertions, 9 deletions
diff --git a/js/console.ts b/js/console.ts
index 1a963558a..ed6040f1d 100644
--- a/js/console.ts
+++ b/js/console.ts
@@ -502,6 +502,14 @@ export class Console {
this.indentLevel = 0;
this.collapsedAt = null;
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 */
diff --git a/js/globals.ts b/js/globals.ts
index 3be55e979..cff4b7dd9 100644
--- a/js/globals.ts
+++ b/js/globals.ts
@@ -51,21 +51,13 @@ window.window = window;
immutableDefine(window, "Deno", 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.
window.atob = textEncoding.atob;
window.btoa = textEncoding.btoa;
window.fetch = fetchTypes.fetch;
window.clearTimeout = timers.clearTimeout;
window.clearInterval = timers.clearInterval;
-window.console = console;
+window.console = new consoleTypes.Console(core.print);
window.setTimeout = timers.setTimeout;
window.setInterval = timers.setInterval;
window.location = (undefined as unknown) as domTypes.Location;