WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
287472
document.caretPositionFromPoint returns null over SVG elements and elements with `-webkit-user-select: none`
https://bugs.webkit.org/show_bug.cgi?id=287472
Summary
document.caretPositionFromPoint returns null over SVG elements and elements w...
Anne van Kesteren
Reported
2025-02-11 00:21:36 PST
<svg width=100 height=100><circle cx=50 cy=50 r=50 /></svg> <script> range = document.caretRangeFromPoint(50, 50); w(range); </script> logs null instead of a range pointing to the svg element. This can make shadow trees containing SVG observable (as we return null rather than a range for the host element). I discovered this in
bug 286803
.
https://software.hixie.ch/utilities/js/live-dom-viewer/?%3Csvg%20width%3D100%20height%3D100%3E%3Ccircle%20cx%3D50%20cy%3D50%20r%3D50%20%2F%3E%3C%2Fsvg%3E%0A%3Cscript%3E%0Arange%20%3D%20document.caretRangeFromPoint(50%2C%2050)%3B%0Aw(range)%3B%0A%3C%2Fscript%3E
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2025-02-18 00:25:08 PST
<
rdar://problem/145038689
>
Brent Fulgham
Comment 2
2025-03-31 13:46:06 PDT
Shouldn't this be `document.caretPositionForPoint()`?
Brent Fulgham
Comment 3
2025-03-31 13:51:47 PDT
https://software.hixie.ch/utilities/js/live-dom-viewer/saved/13608
Anne van Kesteren
Comment 4
2025-03-31 23:27:06 PDT
I'm pretty sure both use the same underlying infrastructure and we need to fix that as this ends up exposing shadow roots when they use SVG.
Aditya Keerthi
Comment 5
2025-08-05 20:53:17 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/48997
Aditya Keerthi
Comment 6
2025-08-06 14:29:16 PDT
Submitted web-platform-tests pull request:
https://github.com/web-platform-tests/wpt/pull/54176
EWS
Comment 7
2025-08-06 18:08:19 PDT
Committed
298313@main
(74c2e1e966aa): <
https://commits.webkit.org/298313@main
> Reviewed commits have been landed. Closing PR #48997 and removing active labels.
Aditya Keerthi
Comment 8
2025-08-21 13:39:11 PDT
***
Bug 287796
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug