aboutsummaryrefslogtreecommitdiff
path: root/frontend/helper.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-08-01 18:40:35 +0200
committermetamuffin <metamuffin@disroot.org>2023-08-01 18:40:35 +0200
commitad2b4207d48fe19e501e0fac2c1139ce7ef4dea1 (patch)
tree0ce3271c6ca517fa81bdf6373c4515eeb5a53387 /frontend/helper.ts
parent7b1cb4e58347758cab25b73dc6486f5f90efa6df (diff)
downloadfastbangs-ad2b4207d48fe19e501e0fac2c1139ce7ef4dea1.tar
fastbangs-ad2b4207d48fe19e501e0fac2c1139ce7ef4dea1.tar.bz2
fastbangs-ad2b4207d48fe19e501e0fac2c1139ce7ef4dea1.tar.zst
submit ui
Diffstat (limited to 'frontend/helper.ts')
-rw-r--r--frontend/helper.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/frontend/helper.ts b/frontend/helper.ts
index f47d131..2ecfc35 100644
--- a/frontend/helper.ts
+++ b/frontend/helper.ts
@@ -5,6 +5,8 @@ interface Opts<E> {
id?: string,
src?: string,
for?: string,
+ type?: string,
+ href?: string,
onclick?: (e: E) => void,
onchange?: (e: E) => void,
}
@@ -14,6 +16,8 @@ function apply_opts<E extends HTMLElement>(e: E, o: Opts<E>) {
if (o.onclick) e.onclick = () => o.onclick!(e)
if (o.onchange) e.onchange = () => o.onchange!(e)
if (o.for) (e as unknown as HTMLLabelElement).htmlFor = o.for
+ if (o.type && e instanceof HTMLInputElement) e.type = o.type
+ if (o.href && e instanceof HTMLAnchorElement) e.href = o.href;
if (typeof o?.class == "string") e.classList.add(o.class)
if (typeof o?.class == "object") e.classList.add(...o.class)
}