in src/helper/dom.ts [185:209]
insertChild = function (
this: ExtendedHTMLElement,
position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend',
child: string | HTMLElement | ExtendedHTMLElement | Array<string | HTMLElement | ExtendedHTMLElement>
): ExtendedHTMLElement {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (child) {
if (child instanceof Array) {
child.forEach(childItem => {
if (childItem instanceof Element) {
this.insertAdjacentElement(position, childItem);
} else if (typeof childItem === 'string') {
this.insertAdjacentText(position, childItem);
}
});
} else {
if (child instanceof Element) {
this.insertAdjacentElement(position, child);
} else if (typeof child === 'string') {
this.insertAdjacentText(position, child);
}
}
}
return this;
};