Description
Firefox has added long-missing support for focusin
/focusout
events in version 63. Other browsers we plan to support in v4 already support the events (apart from Firefox ESR 60 but we’ll drop it before jQuery 4.0 is released).
Currently, we shim focusin
/focusout
in all non-IE browsers both to add support in Firefox and because order of these events is not implemented according to the spec in various browsers. It used to be wild out there but for now the situation is as follows:
Edge 17+, Chrome, Firefox & Safari dispatch the events in the following order:
blur
focusout
focus
focusin
IE 11 follows the spec order, i.e.:
focusout
focusin
blur
focus
jQuery follows the order:
focusout
blur
focusin
focus
The fact that IE follows the spec order is a result of blur
& focus
events being asynchronous there. That’s also why we don’t shim focusin
/focusout
in IE via focus
/blur
as in other browsers as that’d make focusin
/focusout
asynchronous as well. This was considered in #3123.
As you can notice, the jQuery order doesn’t match the spec either, it just fires blur
after focusout
& focus
after focusin
, the rest is different. Since all of the modern browsers settled on a specific non-standard events order, should we just stop shimming it in jQuery 4.0 and rely on native behavior in all browsers?
Leaning towards removing the shim, matching browser behavior, and not guaranteeing execution order.