mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-06 11:01:27 +01:00
Add an ability to specify child elements to makeEl
This commit is contained in:
parent
64f954e686
commit
dc8118df14
1 changed files with 2 additions and 0 deletions
|
@ -61,6 +61,7 @@ export function removeEl<E extends HTMLElement>(...elements: E[] | ConcatArray<E
|
||||||
export function makeEl<Tag extends keyof HTMLElementTagNameMap>(
|
export function makeEl<Tag extends keyof HTMLElementTagNameMap>(
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
attr?: Partial<HTMLElementTagNameMap[Tag]>,
|
attr?: Partial<HTMLElementTagNameMap[Tag]>,
|
||||||
|
children: HTMLElement[] = [],
|
||||||
): HTMLElementTagNameMap[Tag] {
|
): HTMLElementTagNameMap[Tag] {
|
||||||
const el = document.createElement(tag);
|
const el = document.createElement(tag);
|
||||||
if (attr) {
|
if (attr) {
|
||||||
|
@ -71,6 +72,7 @@ export function makeEl<Tag extends keyof HTMLElementTagNameMap>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
el.append(...children);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue