Skip to content
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

Add reusable note to blur, focusout, focusin, focus pages #930

Open
dmethvin opened this issue May 17, 2016 · 11 comments
Open

Add reusable note to blur, focusout, focusin, focus pages #930

dmethvin opened this issue May 17, 2016 · 11 comments

Comments

@dmethvin
Copy link
Member

dmethvin commented May 17, 2016

See jquery/jquery#3123

How about something like this?

Note: Use of focus-related events are complicated by several factors. On Internet Explorer, focus and blur are asynchronous and do not occur at the point where the .focus() method is called in your code. The focusout and focusin events are implemented inconsistently across browsers and not implemented at all on Firefox, although jQuery simulates the event. Code should not depend on the order of focusin and focusout events relative to focus and blur because it varies across browsers. On all platforms, focusout on the previously focused element (if any) will always occur before focusin on the new one, and blur occurs before focus.

@mgol
Copy link
Member

mgol commented May 17, 2016

blur and focusout will occur on the previous element (if any) before focus and focusin occur on the newly focused element

We can only guarantee blur will happen before focus and focusout before focusin. The spec, for instance, mandates that focusin happens before blur and IE 11 follows that.

@mgol
Copy link
Member

mgol commented May 17, 2016

The last sentence sort of replies to what I posted above but the previous one suggests something else. I'd rephrase it.

@dmethvin
Copy link
Member Author

Agreed, we can't guarantee that. Edited.

@kswedberg
Copy link
Member

Hey @dmethvin,
In the last sentence, you can probably drop the first "relative" because it's redundant: "Code should not depend on the order of focusin and focusout events relative to focus and blur…"

@dmethvin
Copy link
Member Author

Changed! There's a "fewer relatives" mother-in-law joke in here somewhere.

@mgol
Copy link
Member

mgol commented May 21, 2016

not implemented at all on Firefox - not in Firefox?

Also, I'd like the text to say focusout will happen before focusin and blur before focus if possible as we do guarantee that.

@dmethvin
Copy link
Member Author

Agreed, updated to reflect that @mgol.

@mgol
Copy link
Member

mgol commented May 23, 2016

Thanks, the note looks good. I only have a grammar question: shouldn't it say in Firefox instead of on Firefox & In Internet Explorer instead of On Internet Explorer? Or have I been using English incorrectly? ;)

@dmethvin
Copy link
Member Author

dmethvin commented Jun 2, 2016

Sorry, i just got to this in my inbox! I think you could use on if you think of a browser as a platform or in as an environment. Either works for me. If you think you use English incorrectly, you should see me with French or Spanish.

@mgol
Copy link
Member

mgol commented Jun 2, 2016

OK, thanks for an explanation, that captures it nicely. I seem to think of a browser as an environment more than a platform so I see where my in comes from. Either works fine. :)

@mgol
Copy link
Member

mgol commented Aug 21, 2019

Note: due to jquery/jquery#4300, jQuery 4.0 will drop the guarantee that focusin fires before focus & focusout before blur; let's make sure to not document that guarantee. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants