@scania/tegel
Version:
Tegel Design System
11 lines (10 loc) • 676 B
TypeScript
/**
* Recursively finds the first matching element or child based on a provided condition.
*
* @param {ParentNode} parentNode - The starting element or shadow root to search from.
* @param {(el: HTMLElement) => boolean} searchPredicate - The condition to match the element, receives an HTMLElement and returns a boolean.
* @param {boolean} [pierceShadow=false] - Whether to pierce through shadow DOM boundaries.
* @returns {HTMLElement | null} - The first matching element or child, or null if none is found.
*/
declare function dfs(parentNode: ParentNode, searchPredicate: (el: HTMLElement) => boolean, pierceShadow?: boolean): HTMLElement | null;
export default dfs;