diff options
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 |
commit | 88f4f42fa5ced5b99d932f524ef3af3347ed6899 (patch) | |
tree | b27de88fbd218cfb03e063a197394225c95a4ef1 /src/util | |
parent | 98c033a6a97b5a8fd2e2405495c7753ccd511d5d (diff) |
html: flatten attribute value arrays infinitely
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/html.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/util/html.js b/src/util/html.js index b4c29b88..2e3204f4 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); } |