diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-12-31 22:07:48 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-01-03 20:45:45 -0400 |
commit | 1a62a7345b73fbf31b084577ae78379dc1585813 (patch) | |
tree | beef2fba3fbab61e9aa05b6b11292a9b60260730 | |
parent | 6447a9ed99e0bc359c146517f47f298e75469a60 (diff) |
html: show symbol count when inspecting attributes
-rw-r--r-- | src/util/html.js | 26 |
1 files changed, 25 insertions, 1 deletions
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}>` + : `<no attributes>`); + + return `Attributes ${contentPart}`; } } |