UNPKG

@fluentui/dom-utilities

Version:

DOM utilities for use within Fluent web components

16 lines 748 B
import { getParent } from './getParent'; /** * Finds the first parent element where the matchFunction returns true * @param element - element to start searching at * @param matchFunction - the function that determines if the element is a match * @returns the matched element or null no match was found */ export function findElementRecursive(element, matchFunction, doc) { // eslint-disable-next-line no-restricted-globals doc !== null && doc !== void 0 ? doc : (doc = document); if (!element || element === doc.body || element instanceof Document) { return null; } return matchFunction(element) ? element : findElementRecursive(getParent(element), matchFunction); } //# sourceMappingURL=findElementRecursive.js.map