Skip to content
Permalink
Browse files

Fix #8732. Change feature detect for focusin event support, so IE9 wo…

…n't have duplicate events.
  • Loading branch information...
dmethvin committed Apr 4, 2011
1 parent b7dd840 commit bbd9c776ea22296a6807d5b760bd4e82ee5f4414
Showing with 2 additions and 1 deletion.
  1. +1 −1 src/event.js
  2. +1 −0 src/support.js
@@ -850,7 +850,7 @@ function trigger( type, elem, args ) {
}

// Create "bubbling" focus and blur events
if ( document.addEventListener ) {
if ( !jQuery.support.focusinBubbles ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {

// Attach a single capturing handler while someone wants focusin/focusout
@@ -226,6 +226,7 @@

jQuery.support.submitBubbles = eventSupported("submit");
jQuery.support.changeBubbles = eventSupported("change");
jQuery.support.focusinBubbles = document.attachEvent && eventSupported("focusin");

This comment has been minimized.

Copy link
@jdalton

jdalton Apr 7, 2011

Member

I believe Opera has 'attachEvent' too. This is kind of a weak inference as non of them test bubbling. Also keep in mind focusin (bubble phase) is diff than focus (capture phase).

This comment has been minimized.

Copy link
@dmethvin

dmethvin Apr 7, 2011

Author Member

Opera does, and it's okay for it to go through this check. I agree these are all pretty weak inferences; I'm just checking to see if focusin is supported and bubbles, not whether the workaround (focus capture phase) can be implemented.

This comment has been minimized.

Copy link
@jdalton

jdalton Apr 7, 2011

Member

eventSupported doesn't check bubbling, just that a function value is created when setting an attribute

This comment has been minimized.

Copy link
@dmethvin

dmethvin Apr 7, 2011

Author Member

True, what I'm testing (is focusin supported on a div) and what I'm asserting as a result (focusin bubbles) are more than a few feet away from each other. However I think it's true for the set of browsers we support. I could nest elements and test for actual bubbling, but since we run this stuff on every page load I figured it was best to keep it light. If the feature detect is wrong I'll go to something more complex.

This comment has been minimized.

Copy link
@jdalton

jdalton Apr 7, 2011

Member

it might be avoided altogether if the workaround is tweaked to avoid focusin completely. Because jQuery can simulate bubbling and you all manage event handler execution order, you could simply set 1 real focus/blur event on an element and have it trigger simulated bubbling. To set the 1 real focus/blur you intercept the focus (capture) of the parent element (at when u call delegate on the parent) and grab the event.target element.


// release memory in IE
div = all = a = null;

2 comments on commit bbd9c77

@dmethvin

This comment has been minimized.

Copy link
Member Author

dmethvin replied Apr 7, 2011

@jdalton, I'm not sure how that differs from what we're doing now at

@jdalton

This comment has been minimized.

Copy link
Member

jdalton replied Apr 7, 2011

Oh cool! Then it should be simple. Would break back compat but it would avoid trying to simulate a focusin and focusout. I did this by having like a delegate:focus event instead so it was something separate.

Please sign in to comment.
You can’t perform that action at this time.