UNPKG

@mui/x-internals

Version:

Utility functions for the MUI X packages (internal use only).

14 lines (13 loc) 465 B
/** * Returns the target element of an event, accounting for shadow DOM. * @param event The event object. * @returns The target element of the event. */ export function getTarget(event) { if ('composedPath' in event) { return event.composedPath()[0] ?? event.target; } // Fallback for environments where `composedPath` is not available. // TS narrows `event` to `never` here because it assumes `composedPath` always exists. return event.target; }