Skip to content

Stop shimming focusin/focusout in jQuery 4.0 #4300

@mgol

Description

@mgol

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:

  1. blur
  2. focusout
  3. focus
  4. focusin

IE 11 follows the spec order, i.e.:

  1. focusout
  2. focusin
  3. blur
  4. focus

jQuery follows the order:

  1. focusout
  2. blur
  3. focusin
  4. 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?

Link to test case

https://jsfiddle.net/66znLhfw/2/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions