Skip to content

Commit a8ea202

Browse files
committed
console, doc, test: corrections following review
Nits in documentation, rework dirxml to use console.log, tests. Fixes: #17128
1 parent 6319499 commit a8ea202

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

doc/api/console.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,13 @@ Defaults to `false`. Colors are customizable; see
282282
added: v8.0.0
283283
changes:
284284
- version: REPLACEME
285-
pr-url: https://github.com/nodejs/node/pull/17128
286-
description: "`console.dirxml` now calls `console.dir` for each argument."
285+
pr-url: https://github.com/nodejs/node/pull/17152
286+
description: "`console.dirxml` now calls `console.log` for its arguments."
287287
-->
288288
* `...data` {any}
289289

290-
This method calls `console.dir()` with default options for each argument it
291-
receives. See [`console.dir()`][] for more details about said defaults.
292-
Please note that this method doesn't produce any xml formatting and uses the
293-
default `console.dir()` formatting resolution instead.
290+
This method calls `console.log()` passing it the arguments received.
291+
Please note that this method does not produce any XML formatting.
294292

295293
### console.error([data][, ...args])
296294
<!-- YAML
@@ -524,7 +522,6 @@ added: v8.0.0
524522
This method does not display anything unless used in the inspector. The
525523
`console.timelineEnd()` method is the deprecated form of [`console.timeEnd()`][].
526524

527-
[`console.dir()`]: #console_console_dir_obj_options
528525
[`console.error()`]: #console_console_error_data_args
529526
[`console.group()`]: #console_console_group_label
530527
[`console.log()`]: #console_console_log_data_args

lib/console.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,7 @@ Console.prototype.dir = function dir(object, options) {
162162
};
163163

164164

165-
Console.prototype.dirxml = function dirxml(...data) {
166-
for (const item of data) {
167-
Console.prototype.dir.call(this, item);
168-
}
169-
};
165+
Console.prototype.dirxml = Console.prototype.log;
170166

171167

172168
Console.prototype.time = function time(label = 'default') {

test/parallel/test-console.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,10 @@ assert.strictEqual(strings.shift(),
179179
"{ foo: 'bar', inspect: [Function: inspect] }\n");
180180
assert.ok(strings.shift().includes('foo: [Object]'));
181181
assert.strictEqual(strings.shift().includes('baz'), false);
182-
assert.strictEqual(strings.shift(),
183-
"{ foo: 'bar', inspect: [Function: inspect] }\n");
184-
assert.strictEqual(strings.shift(),
185-
"{ foo: 'bar', inspect: [Function: inspect] }\n");
186-
assert.strictEqual(strings.shift().includes('foo: { bar: { baz:'), true);
187-
assert.strictEqual(strings.shift().includes('quux'), true);
188-
assert.strictEqual(strings.shift().includes('quux: true'), true);
182+
assert.strictEqual(strings.shift(), 'inspect inspect\n');
183+
assert.ok(strings[0].includes('foo: { bar: { baz:'));
184+
assert.ok(strings[0].includes('quux'));
185+
assert.ok(strings.shift().includes('quux: true'));
189186

190187
assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim()));
191188
assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim()));

0 commit comments

Comments
 (0)