diff options
-rw-r--r-- | src/element.ts | 4 |
1 files changed, 3 insertions, 1 deletions
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<E> { 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 extends HTMLElement>(e: E, o: Opts<E>): (() => 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)) |