From 9da32b4b2e255801307caa8f62b7dd49aafcf96b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 16 Aug 2023 15:19:30 -0300 Subject: html: Attributes: push() util --- src/util/html.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/util/html.js') diff --git a/src/util/html.js b/src/util/html.js index 712a0a68..4e243f7d 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -470,6 +470,18 @@ export class Attributes { return delete this.#attributes[attribute]; } + push(attribute, ...values) { + const oldValue = this.get(attribute); + const newValue = + (Array.isArray(oldValue) + ? oldValue.concat(values) + : oldValue + ? [oldValue, ...values] + : values); + this.set(attribute, newValue); + return newValue; + } + toString() { return Object.entries(this.attributes) .map(([key, val]) => { -- cgit 1.3.0-6-gf8a5