« get me outta code hell

html: flatten attribute value arrays infinitely - 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:19:15 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-01 15:19:32 -0400
commit88f4f42fa5ced5b99d932f524ef3af3347ed6899 (patch)
treeb27de88fbd218cfb03e063a197394225c95a4ef1 /src/util
parent98c033a6a97b5a8fd2e2405495c7753ccd511d5d (diff)
html: flatten attribute value arrays infinitely
Diffstat (limited to 'src/util')
-rw-r--r--src/util/html.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/util/html.js b/src/util/html.js
index b4c29b8..2e3204f 100644
--- a/src/util/html.js
+++ b/src/util/html.js
@@ -644,7 +644,11 @@ export class Attributes {
 
   set(attribute, value) {
     if (value instanceof Template) {
-      return this.set(attribute, Template.resolve(value));
+      value = Template.resolve(value);
+    }
+
+    if (Array.isArray(value)) {
+      value = value.flat(Infinity);
     }
 
     if (value === null || value === undefined) {
@@ -724,6 +728,10 @@ export class Attributes {
       return this.#addOneAttribute(attribute, Template.resolve(value));
     }
 
+    if (Array.isArray(value)) {
+      value = value.flat(Infinity);
+    }
+
     if (!this.has(attribute)) {
       return this.set(attribute, value);
     }