aboutsummaryrefslogtreecommitdiff
path: root/frontend/helper.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/helper.ts')
-rw-r--r--frontend/helper.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/frontend/helper.ts b/frontend/helper.ts
index bfd57f0..8453a18 100644
--- a/frontend/helper.ts
+++ b/frontend/helper.ts
@@ -17,11 +17,12 @@ function apply_opts<E extends HTMLElement>(e: E, o: Opts<E>) {
if (o.id) e.id = o.id
if (o.onclick) e.onclick = () => o.onclick!(e)
if (o.onchange) e.onchange = () => o.onchange!(e)
+ // TODO can we do this properly?
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 (o.rel && e instanceof HTMLAnchorElement) e.rel = o.rel
- if (o.title && e instanceof HTMLAnchorElement) e.title = o.title
+ if (o.type && (e instanceof HTMLInputElement || e instanceof HTMLLinkElement)) e.type = o.type
+ if (o.href && (e instanceof HTMLAnchorElement || e instanceof HTMLLinkElement)) e.href = o.href
+ if (o.rel && (e instanceof HTMLAnchorElement || e instanceof HTMLLinkElement)) e.rel = o.rel
+ if (o.title && (e instanceof HTMLAnchorElement || e instanceof HTMLLinkElement)) e.title = o.title
if (typeof o?.class == "string") e.classList.add(o.class)
if (typeof o?.class == "object") e.classList.add(...o.class)
}