import { Observable } from "rxjs";

export class HtmlElementUtils {


    public static findChildByClassName<T = Element>(children: HTMLCollection, className: string): T {

        let childrenNodeArr = Array.from(children);
        for (let i = 0; i < childrenNodeArr.length; i++) {
            const element = childrenNodeArr[i];
            if (element.classList.contains(className)) {
                return element as T;
            } else if (element.children) {
                let child = this.findChildByClassName(element.children, className)
                if (child) return child as T;
            }
        }
        return null as T;
    }
}
