NEW 218890
REGRESSION (iOS 14): window.getSelection().getRangeAt(0) on iOS 14 WKWebView returns an incorrect startOffset
https://bugs.webkit.org/show_bug.cgi?id=218890
Summary REGRESSION (iOS 14): window.getSelection().getRangeAt(0) on iOS 14 WKWebView ...
xiehaiyan_xhy
Reported 2020-11-13 01:08:41 PST
In iOS 13 WKWebview and other browsers such as Chrome, when call window.getSelection().getRangeAt(0), it will return the tap character index. But on iOS 14 WKWebview, window.getSelection().getRangeAt(0) doesn't return character index, but seems to return a word end index in en language. My question is: Can we fix this to keep the same as other browsers and iOS 13 WKWebView? Details as below: Code: document.addEventListener('click', (event) => { var range = window.getSelection().getRangeAt(0); console.log("startOffset: "+ range.startOffset.toString()); }); Test case 1: Action: There is a sentence in website as "Test click on website", click at the end of "e" in "Test". Output: In iOS 13 WKWebview and other browsers: startOffset: 2 In iOS 14 WKWebview: startOffset: 5 Also in iOS 14 WKWebview the word ending rule is not the same, when click on the first word in the node, return index will include whitespace, as we see in test case 1. But some others return index which not include whitespace as Test case 2. Test case 2: There is a sentence in website as "Test click on website", tap at the end of "l" in "click" Output: In iOS 13 WKWebview and other browsers: startOffset: 7 In iOS 14 WKWebview: startOffset: 10
Attachments
Radar WebKit Bug Importer
Comment 1 2020-11-14 11:54:36 PST
Darin Adler
Comment 2 2020-11-15 15:40:15 PST
Oh no, this sounds like a bad regression. I assume I caused it with my work on the Selection API. Can we make a regression test to demonstrate? I’m really surprised we didn’t have a test.
xiehaiyan_xhy
Comment 3 2020-11-15 22:19:46 PST
Thanks a lot to look into this, Darin! Could you kindly share when the fix will be released to iOS? Thanks!
xiehaiyan_xhy
Comment 4 2020-11-15 22:20:35 PST
And it would be great to regress in other languages besides en, thanks!
Darin Adler
Comment 5 2020-11-16 09:55:40 PST
I’m not looking into it at this time. Just commented. I am inviting someone to help out by creating a regression test.
Darin Adler
Comment 6 2020-11-16 09:58:43 PST
Also would be good to know if anyone has examples of websites affected.
Note You need to log in before you can comment on or make changes to this bug.