Commit 39f9b846 authored by Dave Methvin's avatar Dave Methvin

Fix #10712. Deal with focus/blur morphing to focusin/focusout.

parent 45101de6
......@@ -5,6 +5,7 @@ var rformElems = /^(?:textarea|input|select)$/i,
rhoverHack = /\bhover(\.\S+)?/,
rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
quickParse = function( selector ) {
var quick = rquickIs.exec( selector );
......@@ -247,6 +248,11 @@ jQuery.event = {
namespaces = [],
cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
// focus/blur morphs to focusin/out; ensure we're not firing them right now
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
return;
}
if ( type.indexOf( "!" ) >= 0 ) {
// Exclusive events trigger only for the exact event (no namespaces)
type = type.slice(0, -1);
......@@ -321,8 +327,9 @@ jQuery.event = {
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
bubbleType = special.delegateType || type;
cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
old = null;
for ( cur = elem.parentNode; cur; cur = cur.parentNode ) {
for ( ; cur; cur = cur.parentNode ) {
eventPath.push([ cur, bubbleType ]);
old = cur;
}
......@@ -572,12 +579,10 @@ jQuery.event = {
},
focus: {
delegateType: "focusin",
noBubble: true
delegateType: "focusin"
},
blur: {
delegateType: "focusout",
noBubble: true
delegateType: "focusout"
},
beforeunload: {
......
......@@ -1563,13 +1563,12 @@ test(".live()/.die()", function() {
jQuery("#nothiddendiv div").die("click");
// div must have a tabindex to be focusable
// blur a non-input element, we should force-fire its handlers
// regardless of whether it's burring or not (unlike browsers)
jQuery("#nothiddendiv div")
.attr("tabindex", "0")
.live("blur", function(){
ok( true, "Live div trigger blur." );
})
.focus()
.trigger("blur")
.die("blur");
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment