diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-01 19:34:52 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-01 19:34:52 +0200 |
commit | 33aaa11e8d88edad10dcb953f063b59c38cfe94d (patch) | |
tree | ee2f0156354c04b67cac2e898868accccd7a3b21 /src/element.ts | |
parent | c70c5b970a9d656d31358fa164c249096b2dcf29 (diff) | |
download | jshelper-33aaa11e8d88edad10dcb953f063b59c38cfe94d.tar jshelper-33aaa11e8d88edad10dcb953f063b59c38cfe94d.tar.bz2 jshelper-33aaa11e8d88edad10dcb953f063b59c38cfe94d.tar.zst |
inline style
Diffstat (limited to 'src/element.ts')
-rw-r--r-- | src/element.ts | 2 |
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 |