MCPcopy Create free account
hub / github.com/testing-library/user-event / isCursorAtEnd

Function isCursorAtEnd

src/utils/edit/cursorPosition.ts:4–12  ·  view source on GitHub ↗
(element: Element)

Source from the content-addressed store, hash-verified

2import {getValue} from './getValue'
3
4export function isCursorAtEnd(element: Element) {
5 const {selectionStart, selectionEnd} = getSelectionRange(element)
6
7 return (
8 selectionStart === selectionEnd &&
9 (selectionStart ?? /* istanbul ignore next */ 0) ===
10 (getValue(element) ?? /* istanbul ignore next */ '').length
11 )
12}
13
14export function isCursorAtStart(element: Element) {
15 const {selectionStart, selectionEnd} = getSelectionRange(element)

Callers 1

control.tsFile · 0.90

Calls 2

getSelectionRangeFunction · 0.90
getValueFunction · 0.90

Tested by

no test coverage detected