16 lines
848 B
JavaScript
16 lines
848 B
JavaScript
import { isElementVisibleAndNotHidden } from '../focus';
|
|
import { getDocument } from './getDocument';
|
|
/**
|
|
* Gets the first visible element that matches the given selector
|
|
* @param selector - The selector to use to find potential visible elements
|
|
* @returns The first visible element that matches the selector, otherwise undefined
|
|
*
|
|
* @public
|
|
*/
|
|
export function getFirstVisibleElementFromSelector(selector) {
|
|
var doc = getDocument();
|
|
var elements = doc.querySelectorAll(selector);
|
|
// Iterate across the elements that match the selector and return the first visible/non-hidden element
|
|
return Array.from(elements).find(function (element) { var _a; return isElementVisibleAndNotHidden(element, (_a = doc.defaultView) !== null && _a !== void 0 ? _a : undefined); });
|
|
}
|
|
//# sourceMappingURL=getFirstVisibleElementFromSelector.js.map
|