#16970 closed defect (fixed)
[patch] [cla] on(node, "focusin", ...) calls listener too late on IE9+
Reported by: | bill | Owned by: | Kris Zyp |
---|---|---|---|
Priority: | undecided | Milestone: | 1.8.6 |
Component: | Events | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | #16968 |
Description
on.js has code for map "focusin" and "focusout" types to "focus" and "blur" for browsers that don't support "focusin" and "focusout" natively:
if(has("dom-addeventlistener")){ // normalize focusin and focusout captures = { focusin: "focus", focusout: "blur" }; ...
However, this code runs for IE9+, firefox, and chrome, whereas it really should only run for firefox.
In particular this leads to problems on IE where on(node, "focusin", listener) calls the listener asynchronously. I hit it after [30957] and I guess it led to many of the fixes/workaround in #16926, but #16968 is trickier so perhaps we should fix the real bug rather than working around it.
Attachments (1)
Change History (7)
comment:1 Changed 8 years ago by
Blocking: | 16968 added |
---|
comment:2 Changed 8 years ago by
Milestone: | tbd → 1.9 |
---|---|
Summary: | on(node, "focusin", ...) on IE9+ and chrome → [patch] [cla] on(node, "focusin", ...) calls listener too late on IE9+ |
I'm attaching a patch, does it look OK? True feature testing is quite difficult since webkit supports focusin but there's no clue like element.onfocusin being defined. The true feature test (as listed in http://stackoverflow.com/questions/7337670/how-to-detect-focusin-support) requires attaching an element to the document and actually focusing it, which seems a bit crazy.
For now I just check if element.attachEvent is defined. It's similar to the current code which checks whether element.addEventListener is defined, except that it does the right thing on IE9+ by listening to focusin instead of focus. (To put it another way, you shouldn't assume that addEventListener("focusin", ...) doesn't work just because addEventListener() is defined.)
Changed 8 years ago by
Attachment: | focusin.patch added |
---|
simple patch to stop using workaround code for IE9+, and just use it for firefox (where it's needed) and webkit (where it doesn't hurt)
(In #16968) It turns out this started with [30957] with the root cause of #16970.