mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-06 11:01:27 +01:00
Merge pull request #445 from MareStare/feat/add-ability-to-pass-children-to-make-el
[Part 8] Add an ability to specify child elements to `makeEl`
This commit is contained in:
commit
6f4709e1e4
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