1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-25 01:39:37 +01:00

add className and classList to ElementAttributes

This commit is contained in:
Jan Andrle 2023-09-21 13:36:28 +02:00
parent 0794659104
commit 8df6aa19fe
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB

8
index.d.ts vendored
View File

@ -25,6 +25,10 @@ type AttrsModified= {
* Provide option to add/remove/toggle CSS clasess (index of object) using 1/0/-1. In fact `el.classList.toggle(class_name)` for `-1` and `el.classList.toggle(class_name, Boolean(...))` for others.
*/
classList: Record<string,-1|0|1>,
/**
* By default simiral to `className`, but also supports `string[]`
* */
className: string | (string|boolean|undefined)[];
/**
* Sets `aria-*` simiraly to `dataset`
* */
@ -40,8 +44,8 @@ type AttrsModified= {
*/
type ElementAttributes<T extends keyof ElementTagNameMap | ElementTagNameMap[keyof ElementTagNameMap]>=
T extends keyof ElementTagNameMap ?
Omit<ElementTagNameMap[T],"classList"> & AttrsModified :
Omit<T,"classList"> & AttrsModified;
Omit<ElementTagNameMap[T],"classList"|"className"> & AttrsModified :
Omit<T,"classList"|"className"> & AttrsModified;
export function assign<El extends Element>(element: El, ...attrs_array: ElementAttributes<El>[]): El
type ElementExtender<El extends Element>= (element: El)=> El;