/**
 * Focuses the provided non-interactive element.
 * @param element - HTML element to apply focus to.
 * @param label - Fallback label to apply to the element if focused.
 * @returns Whether the focus was successful or not (eg. element is not visible).
 */
const focusNonInteractiveElement = (element, label) => {
    if (!element.hasAttribute('aria-label') && label) {
        element.setAttribute('aria-label', label);
        element.addEventListener('focusout', () => {
            element.removeAttribute('aria-label');
        }, { once: true });
    }
    if (element.hasAttribute('tabindex')) {
        element.focus();
    }
    else {
        element.setAttribute('tabindex', '-1');
        element.focus();
        element.addEventListener('focusout', () => {
            element.removeAttribute('tabindex');
        }, { once: true });
    }
    return document.activeElement === element;
};
export default focusNonInteractiveElement;
//# sourceMappingURL=focusNonInteractiveElement.js.map