RESOLVED FIXED 273469
REGRESSION (Safari 17): getRangeAt(0) returns the same JS object even after selection changes, differs from Chrome and Firefox
https://bugs.webkit.org/show_bug.cgi?id=273469
Summary REGRESSION (Safari 17): getRangeAt(0) returns the same JS object even after s...
harshitg0202
Reported 2024-04-30 00:54:44 PDT
Hi, a new change in selection and range API has broken my code for a custom find feature in the latest Safari v17. When I use the window.getSelection().getRangeAt(0) on Safari v16, I get new range objects whenever the selection changes. But in the latest Safari v17, window.getSelection().getRangeAt(0) returns always the same range object (updated with new data). This behavior differs from any other browser on windows, linux or mac. Sharing an example snippet here: https://jsfiddle.net/zb85nhx6/1/. Trying running this in different browsers and check the console. This took of lot of debugging to figure out why my code was broken for only latest Safari on Mac. Kindly either fix this behavior to make it seamless with other browsers, or provide an API to turn off live ranges.
Attachments
Reduction (267 bytes, text/html)
2024-10-31 14:46 PDT, Ryosuke Niwa
no flags
Alexey Proskuryakov
Comment 1 2024-04-30 13:04:26 PDT
Interestingly, Chrome has the same behavior with window.getSelection(), the returned object is always the same. But getRangeAt(0) is different when the selection changes.
Radar WebKit Bug Importer
Comment 2 2024-04-30 13:04:38 PDT
Ryosuke Niwa
Comment 3 2024-10-31 14:46:03 PDT
Created attachment 473098 [details] Reduction
Ryosuke Niwa
Comment 4 2024-10-31 19:12:53 PDT
EWS
Comment 5 2024-10-31 21:59:41 PDT
Committed 285996@main (d187066ee9b0): <https://commits.webkit.org/285996@main> Reviewed commits have been landed. Closing PR #36032 and removing active labels.
EWS
Comment 6 2024-12-11 11:37:33 PST
Committed 283286.581@safari-7620-branch (cddad120f97e): <https://commits.webkit.org/283286.581@safari-7620-branch> Reviewed commits have been landed. Closing PR #2396 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.