@jjwesterkamp/event-delegation
Version:
Event delegation for browser DOM events. Flexible, cross-browser compatible and Typescript-focused.
14 lines (13 loc) • 732 B
TypeScript
/**
* Queries up the DOM for given `selector`, starting from given `leafElement`.
* The first element found matching `selector` will be returned.
* Querying will stop as soon as given `root` is encountered.
* If no matching element was found, `null` is returned.
*
* Based on the {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill MDN `closest` polyfill}
*
* @param leaf The innermost element in the DOM tree to start searching from.
* @param selector The selector (CSS style) to match ancestor elements with.
* @param root The element that acts as a scope for the query.
*/
export declare function closestWithin(leaf: HTMLElement, selector: string, root: Node): HTMLElement | null;