-
Notifications
You must be signed in to change notification settings - Fork 458
Closed
Description
caretRangeFromPoint Update Request
Configuration Check
My compilation target is ES2020 and my lib is caretRangeFromPoint.
Missing / Incorrect Definition
caretRangeFromPoint is currently defined as:
caretRangeFromPoint(x: number, y: number): Range;
but should be
caretRangeFromPoint(x: number, y: number): Range | null;
Sample Code
// Calculate range and friends here after we've made our fake textarea/input divs.
range = document.caretRangeFromPoint(ev.clientX, ev.clientY);
const startNode = range.startContainer;
This code should have a type error but currently doesn't since library doens't show return type as nullable. This happens quite often in the wild.
Documentation Link
https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint also shows null as possible return type.
Metadata
Metadata
Assignees
Labels
No labels