« get me outta code hell

html: refactor #stringifyContent - 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-29 18:39:08 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-30 12:29:52 -0400
commitf0013d8fd937f2f1d14608edb7bb36d4c7f7e85c (patch)
treef360dfae870d631cf405ec6e4a851e565c638cd0 /src/util
parent2bee89bdfb3f710bfe08d616e302d781627cb297 (diff)
html: refactor #stringifyContent
Diffstat (limited to 'src/util')
-rw-r--r--src/util/html.js29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/util/html.js b/src/util/html.js
index f13f8c29..4be008ed 100644
--- a/src/util/html.js
+++ b/src/util/html.js
@@ -397,14 +397,27 @@ export class Tag {
     const joiner =
       (this.joinChildren === undefined
         ? '\n'
-        : (this.joinChildren === ''
-            ? ''
-            : `\n${this.joinChildren}\n`));
-
-    return this.content
-      .map(item => item.toString())
-      .filter(Boolean)
-      .join(joiner);
+     : this.joinChildren === ''
+        ? ''
+        : `\n${this.joinChildren}\n`);
+
+    let content = '';
+
+    for (const [index, item] of this.content.entries()) {
+      const itemContent = item.toString();
+
+      if (!itemContent) {
+        continue;
+      }
+
+      if (content) {
+        content += joiner;
+      }
+
+      content += itemContent;
+    }
+
+    return content;
   }
 
   static normalize(content) {