From d20a4fcf83818ead0b0775ded507e9e6f0fcc9b1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 21 Jan 2024 03:16:04 +0100 Subject: placeholders --- src/element.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/element.ts') diff --git a/src/element.ts b/src/element.ts index f7dcb04..da98852 100644 --- a/src/element.ts +++ b/src/element.ts @@ -12,7 +12,8 @@ interface Opts { for?: string, type?: string, href?: string, - style?: { [key in keyof CSSStyleDeclaration]?: CSSStyleDeclaration[key] } + style?: { [key in keyof CSSStyleDeclaration]?: CSSStyleDeclaration[key] }, + placeholder?: string, onclick?: (e: E) => void, onmouseenter?: (e: E) => void, onmouseleave?: (e: E) => void, @@ -24,6 +25,7 @@ function apply_opts(e: E, o: Opts): (() => void) | voi 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.placeholder && e instanceof HTMLInputElement) e.placeholder = o.placeholder; if (o.onclick) e.addEventListener("click", () => o.onclick!(e)) if (o.onchange) e.addEventListener("change", () => o.onchange!(e)) if (o.onmouseenter) e.addEventListener("mouseenter", () => o.onmouseenter!(e)) -- cgit v1.2.3-70-g09d2