mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix #10712. Deal with focus/blur morphing to focusin/focusout.
This commit is contained in:
parent
45101de696
commit
39f9b846e7
15
src/event.js
15
src/event.js
@ -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");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user