-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop shimming focusin
/focusout
in jQuery 4.0
#4300
Comments
I agree this would be great to eliminate as special cases. Currently we allow event delegation on "focus" or "blur" events that do not bubble by using the bubbling "focusin" or "focusout". Ideally we'd just make people use "focusin" or "focusout" for those cases. Although that would be a breaking change it might be worthwhile to require because people would need to look at their code to ensure it's working properly. This should be possible to detect pretty well with Migrate because non-focusable elements (not natively focusable or no |
@dmethvin I mostly meant dropping our custom Would you want to remove that part as well? This would have to be done for I guess we'll see how much of it survives our event rewrite, though |
Oh true, I agree they're independent decisions. As far as focusin/out are concerned I think it would be fine to use the native implementation and document that all these events currently aren't guaranteed (by the browser) to be in the same relative order. |
Leaning towards removing the shim, matching browser behavior, and not guaranteeing execution order. |
One note: while the current order is inconsistent between IE & others, what's consistent (& verified by tests) is that I think we should do it but we should realize that we'll drop this guarantee then. |
Latest versions of all browsers now implement focusin & focusout natively and they all converged on a common event order so it doesn't make much sense for us to normalize it to a different order anymore. Note that it means we no longer guarantee that focusin fires before focus and focusout before blur. Fixes jquerygh-4300
PR: #4362 |
Latest versions of all browsers now implement focusin & focusout natively and they all converged on a common event order so it doesn't make much sense for us to normalize it to a different order anymore. Note that it means we no longer guarantee that focusin fires before focus and focusout before blur. Fixes jquerygh-4300
Latest versions of all browsers now implement focusin & focusout natively and they all converged on a common event order so it doesn't make much sense for us to normalize it to a different order anymore. Note that it means we no longer guarantee that focusin fires before focus and focusout before blur. Fixes jquerygh-4300
Latest versions of all browsers now implement focusin & focusout natively and they all converged on a common event order so it doesn't make much sense for us to normalize it to a different order anymore. Note that it means we no longer guarantee that focusin fires before focus and focusout before blur. Fixes jquerygh-4300
Latest versions of all browsers now implement focusin & focusout natively and they all converged on a common event order so it doesn't make much sense for us to normalize it to a different order anymore. Note that it means we no longer guarantee that focusin fires before focus and focusout before blur. Fixes jquerygh-4300
Latest versions of all browsers now implement focusin & focusout natively and they all converged on a common event order so it doesn't make much sense for us to normalize it to a different order anymore. Note that it means we no longer guarantee that focusin fires before focus and focusout before blur. Fixes gh-4300 Closes gh-4362
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 shimfocusin
/focusout
in IE viafocus
/blur
as in other browsers as that'd makefocusin
/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
afterfocusout
&focus
afterfocusin
, 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?Link to test case
https://jsfiddle.net/66znLhfw/2/
The text was updated successfully, but these errors were encountered: