Please sign in to comment.
lib: make the global console [[Prototype]] an empty object
From the WHATWG console spec: > 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%. Since in Node.js, the Console constructor has been exposed through require('console'), we need to keep the Console constructor but we cannot actually use `new Console` to construct the global console. This patch changes the prototype chain of the global console object, so the console.Console.prototype is not in the global console prototype chain anymore. ``` const proto = Object.getPrototypeOf(global.console); // Before this patch proto.constructor === global.console.Console // After this patch proto.constructor === Object ``` But, we still maintain that ``` global.console instanceof global.console.Console ``` through a custom Symbol.hasInstance function of Console that tests for a special symbol kIsConsole for backwards compatibility. This fixes a case in the console Web Platform Test that we commented out. PR-URL: #23509 Refs: whatwg/console#3 Refs: https://console.spec.whatwg.org/#console-namespace Reviewed-By: Gus Caplan <email@example.com> Reviewed-By: Matteo Collina <firstname.lastname@example.org> Reviewed-By: Tiancheng "Timothy" Gu <email@example.com> Reviewed-By: Denys Otrishko <firstname.lastname@example.org> Reviewed-By: James M Snell <email@example.com> Reviewed-By: Rich Trott <firstname.lastname@example.org> Reviewed-By: Colin Ihrig <email@example.com> Reviewed-By: Sakthipriyan Vairamani <firstname.lastname@example.org> Reviewed-By: John-David Dalton <email@example.com>
- Loading branch information...
Showing with 98 additions and 37 deletions.