aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontend/helper.ts9
-rw-r--r--frontend/search.ts5
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 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)
}
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)
}