Sign up (with export icon)

utils/dom/isdomselectionbackward

Api-module iconmodule

Functions

  • Chevron-right icon

    isDomSelectionBackward( selection ) → boolean

    Returns true if the given selection is backward, that is, if its focus is positioned before its anchor.

    A replacement for reading Selection#direction, which is absent on older engines and reports 'none' for a selection made with the mouse inside a shadow root. The orientation is then recovered from the anchor and focus positions instead, so an answer is always available.

    Parameters

    selection: Selection | ShadowSelection

    The selection to check.

    Returns

    boolean