-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property 'caretPositionFromPoint' does not exist on type 'Document' #49931
Comments
It was removed here: microsoft/TypeScript-DOM-lib-generator#1029 Probably because it's an experimental API with close to no browser support: https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Still the wrong decision IMO. The alternative |
i'm in this exact situation. i need to support either method for the different browsers that support them... kind of: let range;
if (document.caretRangeFromPoint) {
range = document.caretRangeFromPoint(x, y)
} else {
range = document.caretPositionFromPoint(x, y)
} is there a shim i can add to have |
I totally agree with @mike-lischke We need the type-support for both |
#49931 (comment) it's been a year since you left this comment, so hopefully you got some help elsewhere by now, but for anyone else who wants a quick shim for this, here's what I'm using: declare global {
type CaretPosition = {
offsetNode: Node;
offset: number;
}
interface Document {
caretPositionFromPoint?(x: number, y: number): CaretPosition;
}
} it doesn't support |
Bug Report
π Search Terms
caretPositionFromPoint
Property 'caretPositionFromPoint' does not exist on type 'Document'
π Version & Regression Information
β― Playground Link
Doesn't work in 4.4.4: Playground link
Works in 4.3.5: Playground link
π» Code
π Actual behavior
'Document' should have an optional property "caretPositionFromPoint" since it exists in Firefox browser. Link.
π Expected behavior
Property "caretPositionFromPoint" has been removed from 'Document', I was not able to find an explanation of this decision.
The text was updated successfully, but these errors were encountered: