UNPKG

@fluentui/dom-utilities

Version:

DOM utilities for use within Fluent web components

20 lines 928 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findElementRecursive = void 0; var getParent_1 = require("./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 */ 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((0, getParent_1.getParent)(element), matchFunction); } exports.findElementRecursive = findElementRecursive; //# sourceMappingURL=findElementRecursive.js.map