From 181cfc9fb5bd2cbb7cd0a994a845e1901d256770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E6=B8=A1?= Date: Wed, 17 Jul 2019 21:42:04 +0800 Subject: Adjust console constructor (#2649) https://github.com/denoland/deno/pull/2073#discussion_r303401539 --- js/console.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/console.ts') 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 */ -- cgit v1.2.3