import { getActiveElement } from "./getActiveElement" ; import { contains } from "./contains" ; example export function hasFocusWithin ( element ) { const activeElement = getActiveElement ( element ) ; if ( ! activeElement ) return false ; if ( contains ( element , activeElement ) ) return true ; const activeDescendant = activeElement . getAttribute ( "aria-activedescendant" ) ; if ( ! activeDescendant ) return false ; if ( activeDescendant === element . id ) return true ; return ! ! element . querySelector ( `#${ activeDescendant }` ) ; }