From 6463a75b44a4f7aad6ffe04d0c5ae073fb5ca137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E6=B8=A1?= Date: Wed, 3 Apr 2019 20:37:01 +0800 Subject: web-compatibility console (#2042) --- js/globals.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'js/globals.ts') diff --git a/js/globals.ts b/js/globals.ts index 56956b4ad..93fe6dbe7 100644 --- a/js/globals.ts +++ b/js/globals.ts @@ -46,13 +46,20 @@ window.window = window; 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)); + // Globally available functions and object instances. window.atob = textEncoding.atob; window.btoa = textEncoding.btoa; window.fetch = fetchTypes.fetch; window.clearTimeout = timers.clearTimer; window.clearInterval = timers.clearTimer; -window.console = new consoleTypes.Console(core.print); +window.console = console; window.setTimeout = timers.setTimeout; window.setInterval = timers.setInterval; window.location = (undefined as unknown) as domTypes.Location; -- cgit v1.2.3