lib: make console writable and non-enumerable
According to the standard the property descriptor of console should be writable and non-enumerable. PR-URL: https://github.com/nodejs/node/pull/17708 Fixes: https://github.com/nodejs/node/issues/11805 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
This commit is contained in:
parent
f054855bbf
commit
e99ae7764d
6
lib/internal/bootstrap_node.js
vendored
6
lib/internal/bootstrap_node.js
vendored
@ -321,10 +321,8 @@
|
|||||||
const wrappedConsole = NativeModule.require('console');
|
const wrappedConsole = NativeModule.require('console');
|
||||||
Object.defineProperty(global, 'console', {
|
Object.defineProperty(global, 'console', {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: false,
|
||||||
get() {
|
value: wrappedConsole
|
||||||
return wrappedConsole;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setupInspector(originalConsole, wrappedConsole, Module);
|
setupInspector(originalConsole, wrappedConsole, Module);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ function a() {
|
|||||||
try {
|
try {
|
||||||
return a();
|
return a();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
compiledConsole = consoleDescriptor.get();
|
compiledConsole = consoleDescriptor.value;
|
||||||
if (compiledConsole.log) {
|
if (compiledConsole.log) {
|
||||||
// Using `console.log` itself might not succeed yet, but the code for it
|
// Using `console.log` itself might not succeed yet, but the code for it
|
||||||
// has been compiled.
|
// has been compiled.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user