Files
starface-outlook-sync-addin/node_modules/@fluentui/dom-utilities/lib-commonjs/findElementRecursive.js
T
Stefan Hacker 37ad745546 first commit
2026-04-03 09:38:48 +02:00

20 lines
928 B
JavaScript

"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