Add an ability to specify child elements to makeEl

This commit is contained in:
MareStare 2025-03-04 03:58:23 +00:00
parent 64f954e686
commit dc8118df14

View file

@ -61,6 +61,7 @@ export function removeEl<E extends HTMLElement>(...elements: E[] | ConcatArray<E
export function makeEl<Tag extends keyof HTMLElementTagNameMap>(
tag: Tag,
attr?: Partial<HTMLElementTagNameMap[Tag]>,
children: HTMLElement[] = [],
): HTMLElementTagNameMap[Tag] {
const el = document.createElement(tag);
if (attr) {
@ -71,6 +72,7 @@ export function makeEl<Tag extends keyof HTMLElementTagNameMap>(
}
}
}
el.append(...children);
return el;
}