diff options
-rw-r--r-- | doc/api/util.md | 5 | ||||
-rw-r--r-- | lib/internal/util/inspect.js | 6 | ||||
-rw-r--r-- | test/parallel/test-util-format.js | 6 |
3 files changed, 15 insertions, 2 deletions
diff --git a/doc/api/util.md b/doc/api/util.md index 46637941df..1c9b98c079 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -185,6 +185,9 @@ property take precedence over `--trace-deprecation` and <!-- YAML added: v0.5.3 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/29606 + description: The `%c` specifier is ignored now. - version: v11.4.0 pr-url: https://github.com/nodejs/node/pull/23708 description: The `%d`, `%f` and `%i` specifiers now support Symbols @@ -240,6 +243,8 @@ corresponding argument. Supported specifiers are: * `%O` - `Object`. A string representation of an object with generic JavaScript object formatting. Similar to `util.inspect()` without options. This will show the full object not including non-enumerable properties and proxies. +* `%c` - `CSS`. This specifier is currently ignored, and will skip any CSS + passed in. * `%%` - single percent sign (`'%'`). This does not consume an argument. * Returns: {string} The formatted string diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 8ab3df8b63..de044447b3 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1621,7 +1621,6 @@ function formatWithOptions(inspectOptions, ...args) { tempStr = inspect(args[++a], inspectOptions); break; case 111: // 'o' - { tempStr = inspect(args[++a], { ...inspectOptions, showHidden: true, @@ -1629,7 +1628,6 @@ function formatWithOptions(inspectOptions, ...args) { depth: 4 }); break; - } case 105: // 'i' const tempInteger = args[++a]; if (typeof tempInteger === 'bigint') { @@ -1648,6 +1646,10 @@ function formatWithOptions(inspectOptions, ...args) { tempStr = formatNumber(stylizeNoColor, parseFloat(tempFloat)); } break; + case 99: // 'c' + a += 1; + tempStr = ''; + break; case 37: // '%' str += first.slice(lastPos, i); lastPos = i + 1; diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js index a83a6f3c20..810e9ac114 100644 --- a/test/parallel/test-util-format.js +++ b/test/parallel/test-util-format.js @@ -317,6 +317,12 @@ assert.strictEqual(util.format('abc%', 1), 'abc% 1'); assert.strictEqual(util.format('%i', 1, 'number'), '1 number'); assert.strictEqual(util.format('%i', 1, () => {}), '1 [Function (anonymous)]'); +// %c from https://console.spec.whatwg.org/ +assert.strictEqual(util.format('%c'), '%c'); +assert.strictEqual(util.format('%cab'), '%cab'); +assert.strictEqual(util.format('%cab', 'color: blue'), 'ab'); +assert.strictEqual(util.format('%cab', 'color: blue', 'c'), 'ab c'); + { const o = {}; o.o = o; |