From 1a62a7345b73fbf31b084577ae78379dc1585813 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 31 Dec 2023 22:07:48 -0400 Subject: html: show symbol count when inspecting attributes --- src/util/html.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/html.js b/src/util/html.js index 040714ef..2229394d 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -929,7 +929,31 @@ export class Attributes { } [inspect.custom]() { - return `Attributes <${this.toString({color: true}) || 'no attributes'}>`; + const visiblePart = this.toString({color: true}); + + const numSymbols = Object.getOwnPropertySymbols(this.#attributes).length; + const numSymbolsPart = + (numSymbols >= 2 + ? `${numSymbols} symbol` + : numSymbols === 1 + ? `1 symbol` + : ``); + + const symbolPart = + (visiblePart && numSymbolsPart + ? `(+${numSymbolsPart})` + : numSymbols + ? `(${numSymbolsPart})` + : ``); + + const contentPart = + (visiblePart && symbolPart + ? `<${visiblePart} ${symbolPart}>` + : visiblePart || symbolPart + ? `<${visiblePart || symbolPart}>` + : ``); + + return `Attributes ${contentPart}`; } } -- cgit 1.3.0-6-gf8a5