UNPKG

vuestic-ui

Version:
34 lines (33 loc) 787 B
const isHTMLElement = (el) => { return el instanceof HTMLElement; }; const focusElement = (el) => { if (!el || !isHTMLElement(el)) { return; } el.focus(); el.dispatchEvent(new FocusEvent("focus", { bubbles: true })); }; const blurElement = (el) => { if (!el || !isHTMLElement(el)) { return; } el.blur(); el.dispatchEvent(new Event("blur", { bubbles: true })); }; const focusFirstFocusableChild = (el) => { if (el.tabIndex !== -1) { focusElement(el); return; } const focusable = el.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); if (focusable) { focusElement(focusable); } }; export { focusElement as a, blurElement as b, focusFirstFocusableChild as f }; //# sourceMappingURL=focus.mjs.map