From 88f4f42fa5ced5b99d932f524ef3af3347ed6899 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 31 Dec 2023 22:19:15 -0400 Subject: html: flatten attribute value arrays infinitely --- src/util/html.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/util/html.js') 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); } -- cgit 1.3.0-6-gf8a5