@mui/material
Version:
Material UI is an open-source React component library that implements Google's Material Design. It's comprehensive and can be used in production out of the box.
13 lines (12 loc) • 494 B
JavaScript
export const FOCUSABLE_ATTRIBUTE = 'data-mui-focusable';
/**
* Returns the element marked as the initial focus target inside a focus trap.
* The root element takes precedence over marked descendants so components can
* opt into focusing their own root surface directly.
*/
export function getFocusTarget(rootElement) {
if (!rootElement) {
return null;
}
return rootElement.hasAttribute(FOCUSABLE_ATTRIBUTE) ? rootElement : rootElement.querySelector(`[${FOCUSABLE_ATTRIBUTE}]`);
}