« get me outta code hell

html: show symbol count when inspecting attributes - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
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
commit1a62a7345b73fbf31b084577ae78379dc1585813 (patch)
treebeef2fba3fbab61e9aa05b6b11292a9b60260730 /src/util
parent6447a9ed99e0bc359c146517f47f298e75469a60 (diff)
html: show symbol count when inspecting attributes
Diffstat (limited to 'src/util')
-rw-r--r--src/util/html.js26
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}`;
   }
 }