From 1951cc978eb0a4d983e2aa6122b3afe0e32ad54f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 14 Aug 2023 20:20:47 +0200 Subject: fix apply_opts for --- frontend/helper.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'frontend/helper.ts') 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: E, o: Opts) { 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) } -- cgit v1.2.3-70-g09d2