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 +++++---- frontend/search.ts | 5 +++-- 2 files changed, 8 insertions(+), 6 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: 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) } diff --git a/frontend/search.ts b/frontend/search.ts index 3e510cb..bca2fc0 100644 --- a/frontend/search.ts +++ b/frontend/search.ts @@ -22,7 +22,7 @@ export function section_search(engine: string) { const heading = e("h1", {}, engine) bangs.then(bangs => heading.textContent = bangs[engine]?.name ?? engine) - const input = e("input", {type: "text"}) + const input = e("input", { type: "text" }) input.addEventListener("keydown", ev => { if (ev.code == "Enter") process_query(engine, input.value ?? "") }) @@ -51,6 +51,7 @@ function link_engine(engine: string) { id: "search-link", type: "application/opensearchdescription+xml", href: `/search.xml?default=${encodeURIComponent(engine)}`, - title: `Fastbangs (default engine: ${engine})`}) + title: `Fastbangs (default engine: ${engine})` + }) document.head.append(link) } -- cgit v1.2.3-70-g09d2