diff options
author | metamuffin <metamuffin@disroot.org> | 2023-08-14 20:20:47 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-08-14 20:20:47 +0200 |
commit | 1951cc978eb0a4d983e2aa6122b3afe0e32ad54f (patch) | |
tree | 3bea14efba5371e1c5f313ed86b252973b0384a5 /frontend/helper.ts | |
parent | 9695158014c803c192f30dbd967d2200edce0250 (diff) | |
download | fastbangs-1951cc978eb0a4d983e2aa6122b3afe0e32ad54f.tar fastbangs-1951cc978eb0a4d983e2aa6122b3afe0e32ad54f.tar.bz2 fastbangs-1951cc978eb0a4d983e2aa6122b3afe0e32ad54f.tar.zst |
fix apply_opts for <link>
Diffstat (limited to 'frontend/helper.ts')
-rw-r--r-- | frontend/helper.ts | 9 |
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) } |