Event: provide verbose info for focus(in | out) & rename support props

Ref c074006a69
Ref gh-2312
This commit is contained in:
Oleg Gaidarenko 2015-05-19 13:08:01 +03:00
parent 8d88cd599f
commit 401a351bd2
3 changed files with 53 additions and 46 deletions

View File

@ -828,7 +828,7 @@ jQuery.each({
});
// IE submit delegation
if ( !support.submitBubbles ) {
if ( !support.submit ) {
jQuery.event.special.submit = {
setup: function() {
@ -845,11 +845,11 @@ if ( !support.submitBubbles ) {
elem.form :
undefined;
if ( form && !jQuery._data( form, "submitBubbles" ) ) {
if ( form && !jQuery._data( form, "submit" ) ) {
jQuery.event.add( form, "submit._submit", function( event ) {
event._submitBubble = true;
});
jQuery._data( form, "submitBubbles", true );
jQuery._data( form, "submit", true );
}
});
// return undefined since we don't need an event listener
@ -878,7 +878,7 @@ if ( !support.submitBubbles ) {
}
// IE change delegation and checkbox/radio fix
if ( !support.changeBubbles ) {
if ( !support.change ) {
jQuery.event.special.change = {
@ -908,13 +908,13 @@ if ( !support.changeBubbles ) {
jQuery.event.add( this, "beforeactivate._change", function( e ) {
var elem = e.target;
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
jQuery.event.add( elem, "change._change", function( event ) {
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
jQuery.event.simulate( "change", this.parentNode, event, true );
}
});
jQuery._data( elem, "changeBubbles", true );
jQuery._data( elem, "change", true );
}
});
},
@ -938,14 +938,21 @@ if ( !support.changeBubbles ) {
};
}
// Create "bubbling" focus and blur events
if ( !support.focusinBubbles ) {
// Support: Firefox
// Firefox doesn't have focus(in | out) events
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
//
// Support: Chrome, Safari
// focus(in | out) events fire after focus & blur events,
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
if ( !support.focusin ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) {
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
};
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
};
jQuery.event.special[ fix ] = {
setup: function() {

View File

@ -6,14 +6,14 @@ define([
var i, eventName,
div = document.createElement( "div" );
// Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
// Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
for ( i in { submit: true, change: true, focusin: true }) {
eventName = "on" + i;
if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
if ( !(support[ i ] = eventName in window) ) {
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
div.setAttribute( eventName, "t" );
support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
support[ i ] = div.attributes[ eventName ].expando === false;
}
}

View File

@ -75,7 +75,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"ajax": true,
"attributes": true,
"boxSizingReliable": true,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
@ -83,7 +83,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -100,14 +100,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": false,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": false,
@ -115,7 +115,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": true,
"focusin": true,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -132,14 +132,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /msie 9\.0/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": false,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": false,
@ -147,7 +147,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": true,
"focusin": true,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -164,14 +164,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /msie 8\.0/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": false,
"boxSizingReliable": false,
"changeBubbles": false,
"change": false,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
@ -179,7 +179,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": false,
"cssFloat": false,
"deleteExpando": false,
"focusinBubbles": true,
"focusin": true,
"html5Clone": false,
"htmlSerialize": false,
"input": false,
@ -196,14 +196,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": false,
"reliableMarginRight": true,
"style": false,
"submitBubbles": false
"submit": false
};
} else if ( /8.0(\.\d+|) safari/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": true,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
@ -211,7 +211,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": false,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -228,14 +228,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /(6|7)\.0(\.\d+|) safari/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": true,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
@ -243,7 +243,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -260,14 +260,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /firefox/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": true,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
@ -275,7 +275,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -292,14 +292,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /iphone os 8/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": true,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
@ -307,7 +307,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": false,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -324,14 +324,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /iphone os (6|7)/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": true,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
@ -339,7 +339,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -356,14 +356,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /android 4\.[0-3]/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": true,
"changeBubbles": true,
"change": true,
"checkClone": false,
"checkOn": false,
"clearCloneStyle": true,
@ -371,7 +371,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -388,14 +388,14 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"style": true,
"submitBubbles": true
"submit": true
};
} else if ( /android 2\.3/i.test( userAgent ) ) {
expected = {
"ajax": true,
"attributes": true,
"boxSizingReliable": true,
"changeBubbles": true,
"change": true,
"checkClone": true,
"checkOn": false,
"clearCloneStyle": false,
@ -403,7 +403,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
@ -420,7 +420,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"reliableHiddenOffsets": true,
"reliableMarginRight": false,
"style": true,
"submitBubbles": true
"submit": true
};
}