/*!
 * Built by ShiftSoftware
 * Copyright (c)
 */
export default function childrenWithTag(root, tag) {
    const matchedElements = [];
    function traverse(node) {
        if (node.nodeType === Node.ELEMENT_NODE) {
            const el = node;
            if (el.tagName.toLowerCase().startsWith(tag) && root !== el) {
                matchedElements.push(el);
            }
            const shadowRoot = el === null || el === void 0 ? void 0 : el.shadowRoot;
            if (shadowRoot)
                traverse(shadowRoot);
            Array.from(el.children).forEach(traverse);
        }
        else if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
            Array.from(node.children).forEach(traverse);
        }
    }
    traverse(root);
    return matchedElements;
}
