Sign up (with export icon)

utils/dom/getrangefrommouseevent

Api-module iconmodule

Functions

  • Chevron-right icon

    getRangeFromMouseEvent( domEvent ) → Range | null

    Returns a DOM range from a given point specified by a mouse event.

    Note: The point is resolved inside the shadow root the event was dispatched in, so a click inside a shadow tree gives a range in that tree rather than one at its host. Works for open and closed shadow roots alike, on the engines that honor the shadowRoots option of Document#caretPositionFromPoint(); elsewhere the range still lands beside the host.

    Parameters

    domEvent: MouseEvent & object

    The mouse event.

    Returns

    Range | null

    The DOM range.