« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/html.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util/html.js b/src/util/html.js
index cb4a84e8..3f89a280 100644
--- a/src/util/html.js
+++ b/src/util/html.js
@@ -107,7 +107,13 @@ export class Tag {
   }
 
   set content(value) {
-    if (this.selfClosing) {
+    if (
+      this.selfClosing &&
+      !(value === null ||
+        value === undefined ||
+        !Boolean(value) ||
+        Array.isArray(value) && value.filter(Boolean).length === 0)
+    ) {
       throw new Error(`Tag <${this.tagName}> is self-closing but got content`);
     }
 
@@ -331,7 +337,7 @@ export class Attributes {
         else if (typeof val === 'number')
           return [key, val.toString(), true];
         else if (Array.isArray(val))
-          return [key, val.filter(Boolean).join(' '), keep ?? val.length > 0];
+          return [key, val.filter(Boolean).join(' '), val.length > 0];
         else
           throw new Error(`Attribute value for ${key} should be primitive or array, got ${typeof val}`);
       })