import { hasFocus } from "./hasFocus" ; type EnsureFocusOptions = FocusOptions & { isActive ? : typeof hasFocus ; } ; example returns { number } export function ensureFocus ( element , { preventScroll , isActive = hasFocus } = { } ) { if ( isActive ( element ) ) return - 1 ; element . focus ( { preventScroll } ) ; if ( isActive ( element ) ) return - 1 ; return requestAnimationFrame ( ( ) => { element . focus ( { preventScroll } ) ; } ) ; }