aboutsummaryrefslogtreecommitdiffstats
path: root/app/dom.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/dom.js')
-rw-r--r--app/dom.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/dom.js b/app/dom.js
index 4419205..8e73a09 100644
--- a/app/dom.js
+++ b/app/dom.js
@@ -120,6 +120,20 @@ export class Dom {
}
/**
+ * Create a `<a>`
+ * @param {DomOptions} o
+ */
+ static a(o) {
+ const link = document.createElement("a");
+ Object.assign(link.style, o.styles);
+ if (o.id) link.id = o.id;
+ for (const cls of o.classes) link.classList.add(cls);
+ for (const [k, v] of Object.entries(o.attributes)) link.setAttribute(k, v);
+ if (o.children) link.append(...o.children);
+ return link;
+ }
+
+ /**
* Create a `<label>`
* @param {string} to
* @param {string} text