« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/util/html.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/html.js b/src/util/html.js
index 310e5a76..6e892031 100644
--- a/src/util/html.js
+++ b/src/util/html.js
@@ -617,6 +617,8 @@ export class Tag {
     let content = '';
     let blockwrapClosers = '';
 
+    let seenSiblingIndependentContent = false;
+
     const chunkwrapSplitter =
       (this.chunkwrap
         ? this.#getAttributeString('split')
@@ -671,6 +673,10 @@ export class Tag {
         continue;
       }
 
+      if (!(item instanceof Tag && item.onlyIfSiblings)) {
+        seenSiblingIndependentContent = true;
+      }
+
       const chunkwrapChunks =
         (typeof item === 'string' && chunkwrapSplitter
           ? itemContent.split(chunkwrapSplitter)
@@ -743,6 +749,12 @@ export class Tag {
       }
     }
 
+    // If we've only seen sibling-dependent content (or just no content),
+    // then the content in total is blank.
+    if (!seenSiblingIndependentContent) {
+      return '';
+    }
+
     if (chunkwrapSplitter) {
       if (seenChunkwrapSplitter) {
         content += '</span>';