aboutsummaryrefslogtreecommitdiff
path: root/src/element.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/element.ts')
-rw-r--r--src/element.ts2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/element.ts b/src/element.ts
index 354b976..ed86cfe 100644
--- a/src/element.ts
+++ b/src/element.ts
@@ -12,6 +12,7 @@ interface Opts<E> {
for?: string,
type?: string,
href?: string,
+ style?: { [key in keyof CSSStyleDeclaration]?: CSSStyleDeclaration[key] }
onclick?: (e: E) => void,
onchange?: (e: E) => void,
}
@@ -25,6 +26,7 @@ function apply_opts<E extends HTMLElement>(e: E, o: Opts<E>): (() => void) | voi
if (o.onchange) e.addEventListener("change", () => o.onchange!(e))
if (typeof o?.class == "string") e.classList.add(o.class)
if (typeof o?.class == "object") e.classList.add(...o.class)
+ if (o.style) for (const k in o.style) { const v = o.style[k]; if (v !== undefined) e.style[k] = v }
}
type EEl<K extends keyof HTMLElementTagNameMap> = string