html
                                
                                 html copied to clipboard
                                
                                    html copied to clipboard
                            
                            
                            
                        Add focusin and focusout events
These events are already implemented in browsers and are documented on MDN. This PR also adds onfocusin and onfocusout event handler content attributes.
https://github.com/whatwg/html/issues/3514 tracks this and other focus events.
Fixes https://github.com/whatwg/html/issues/10234
- [x] At least two implementers are interested (and none opposed):
- Chromium already implements
- WebKit already implements
- Gecko already implements
 
- [x] Tests are written and can be reviewed and commented upon at:
- https://wpt.fyi/results/uievents/order-of-events/focus-events
- https://github.com/web-platform-tests/wpt/pull/45432
 
- [x] Implementation bugs are filed:
- Chromium: https://issues.chromium.org/issues/330759712
- Gecko: https://bugzilla.mozilla.org/show_bug.cgi?id=1886428
- WebKit: Already implements onfocusin/onfocusout
 
- [x] MDN issue is filed: https://github.com/mdn/content/issues/32884
- [x] The top of this comment includes a clear commit message to use.
(See WHATWG Working Mode: Changes for more details.)
/dom.html ( diff ) /indices.html ( diff ) /interaction.html ( diff ) /webappapis.html ( diff )
Browsing Blink source code I found these interesting if statements:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/page/focus_controller.cc;l=434;drc=2a6270727b6a7bbcd17ab585dc81ea4fc5a44d71
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/page/focus_controller.cc;l=445?q=DOMFocusIn&ss=chromium
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/dom/document.cc;l=5601-5607;drc=ebef5d0e968e4b5519062305af9856f53c41eb2f
I think these can have interesting impacts if you call focus()/blur() inside of a focus/blur event handler. Doing so might prevent focusin / focusout from being fired.
Should we add that to the spec? Do we have tests for such cases?
Should we add that to the spec?
Nice, definitely!
Do we have tests for such cases?
I removed the logic in a chromium patch and am running all tests on it now to find out