Repository navigation
console - writable property #11805
Description
Activity
- addedconsoleIssues and PRs related to the console subsystem.Issues and PRs related to the console subsystem.
on Mar 11, 2017 Sounds OK to me, @Wandalen, are you going to PR this?
- addedfeature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
on Mar 23, 2017 OK fixing or OK leaving as is? :) I would be glad to make a pull request.
@Wandalen If you want, you can open a PR; the code you’ll want to look at is in
setupGlobalConsole()inlib/internal/bootstrap_node.js.It’s not as simple as just switching a boolean, though; I think you might need to do something like
addBuiltinLibsToObject()inlib/internal/module.jsto work around the fact that we currently need a getter mechanism forglobal.console.I think it’s both ok to fix this and to leave it as is – the property is still configurable, so if you really want to, you can
delete global.console; global.console = …;already.Let us know if you have any questions or there’s something we can help with!
Yes, sure, I will do. Thank you for hints, Addaleax.
FYI: I think you could pick a test from WPT to test writable console as like test-whatwg-url-constructor.js.
Reacted by WandalenUnderstood, thank you. Will find free time soon.
The first commit makes console overridable without delete with minimum changes.
The second commit makes console writable, not enumerable and give property descriptor value field as it supposes to be according to the standard.
One more test case stays commented out.
A prototype of a console should have own none fields according to the standard, but currently, have:
'constructor',
'log',
'info',
'warn',
'error',
'dir',
'time',
'timeEnd',
'trace',
'assert'
Please let me know should I make corresponding adjustments to make the test case pass.A prototype of a console should have own none fields according to the standard
That is true, but Node.js has always had
consoleas an instance ofrequire('console').Console, and it might be unfortunately too late to change that now due to backwards compatibility requirements.@TimothyGu changes which you requested break test suite.
@TimothyGu thanks for your suggestions. Regarding the test case, I can try. Do you think that aspect of functionality covered by tests good enough to trust them? Currently, don't see why it would be impossible.
@TimothyGu, @watilde, @addaleax, @sam-github, @bnoordhuis, @Fishrock123 do you want any other adjustment? Can I be useful with other related issue?
I revived #12454 in the hopes of getting it landed (or, if there are firm objections to the whole concept, closed).
- added 2 commits that reference this issue
on Jan 17, 2018 - added a commit that references this issue
on May 8, 2018
I am writing testing utilities and have trouble on nodejs platform ridding off unwanted output.
"console" is writable property in a browser. On nodejs "console's" methods could be rewritten iterating them, so making "console" non-writable does not give any insurance, but only make solving of my problem and similar more tedious. From my point of view having "console" non-writable counter-intuitive neither reasonable.
I propose to return writability to "console".