Skip to content

Shim focusin/focusout in all browsers? #3123

Closed
@mgol

Description

Description
If focusout & blur handlers are attached on one input and focusin & focus on the second one, the order of events fired by jQuery is:

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

The order mandated by the spec and followed by IE 11 is:

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

EDIT: IE is not following the spec, though, as it fires only focusout & focusin synchronously and blur/focus asynchronously. This has been fixed in Edge and now all events are fired synchronously as in other browsers.

(The spec also mandates that focus is lost after focusout & before blur and gained after focusin but before focus event fires).

Chrome/Safari do the following:

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

Edge 13 does the following:

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

Firefox doesn't support those events yet but there's ongoing work in https://bugzilla.mozilla.org/show_bug.cgi?id=687787.

We're currently polyfilling this event everywhere except in IE. Since IE differs from our implementation and it's an obsolete browser it sounds bad to let it do its own thing different than what we have. Should we just shim everywhere?

Link to test case
https://jsfiddle.net/66znLhfw/2/

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions