WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
27019
window.getSelection().focusNode is null with onfocus handler registered
https://bugs.webkit.org/show_bug.cgi?id=27019
Summary
window.getSelection().focusNode is null with onfocus handler registered
Jessie Berlin
Reported
2009-07-06 20:00:12 PDT
Created
attachment 32354
[details]
Test case for window.getSelection with onfocus, onclick handlers When an onfocus handler is registered on a div containing another div with text, window.getSelection().focusNode reports null in said onfocus handler. If the handler is an onclick handler, it correctly reports the focusNode as a HTML div element.
Attachments
Test case for window.getSelection with onfocus, onclick handlers
(2.27 KB, text/html)
2009-07-06 20:00 PDT
,
Jessie Berlin
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2010-10-26 22:18:27 PDT
This is due to the fact WebKit sets selection after setting the focus.
Ryosuke Niwa
Comment 2
2010-10-26 22:19:37 PDT
Ojan, Alexey: Do you think we should change the WebKit's behavior so that we set the selection first and then focus? This will make our behavior consistent with IE.
Alexey Proskuryakov
Comment 3
2010-10-26 22:37:14 PDT
> This will make our behavior consistent with IE.
Have you tested Firefox? I'm not aware of any reason why such a change would be bad per se. But I don't think that we allow unfocused (inactive? I'm confused about the difference) elements/frames to be selected, because having multiple selections in a window is bad UI.
Ryosuke Niwa
Comment 4
2011-03-03 22:47:11 PST
FocusController / SelectionController is in the realm of the HTML Editing component.
Ahmad Saleem
Comment 5
2022-07-30 10:22:36 PDT
Latest test results across all browsers: *** Safari 15.6 on macOS ***
> Clicking on 'Red' padding
window.getSelection(): window.getSelection().focusNode: null
> Clicking on 'Blue' padding
window.getSelection(): window.getSelection().focusNode: [object Text] window.getSelection().focusNode.parentNode: [object HTMLDivElement] *** Chrome Canary 106 *** [MATCH WITH SAFARI]
> Clicking on 'Red' padding
window.getSelection(): window.getSelection().focusNode: null
> Clicking on 'Blue' padding
window.getSelection(): window.getSelection().focusNode: [object Text] window.getSelection().focusNode.parentNode: [object HTMLDivElement] *** Firefox Nightly 105 ***
> Clicking on 'Red' padding
window.getSelection(): window.getSelection().focusNode: [object Text] window.getSelection().focusNode.parentNode: [object HTMLDivElement]
> Clicking on 'Blue' padding
window.getSelection(): window.getSelection().focusNode: [object Text] window.getSelection().focusNode.parentNode: [object HTMLDivElement] ___________ I am not sure on web-spec but just wanted to share latest results across all browsers using attached test case. Thanks!
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