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 // IE submit delegation
if ( !support.submitBubbles ) { if ( !support.submit ) {
jQuery.event.special.submit = { jQuery.event.special.submit = {
setup: function() { setup: function() {
@ -845,11 +845,11 @@ if ( !support.submitBubbles ) {
elem.form : elem.form :
undefined; undefined;
if ( form && !jQuery._data( form, "submitBubbles" ) ) { if ( form && !jQuery._data( form, "submit" ) ) {
jQuery.event.add( form, "submit._submit", function( event ) { jQuery.event.add( form, "submit._submit", function( event ) {
event._submitBubble = true; event._submitBubble = true;
}); });
jQuery._data( form, "submitBubbles", true ); jQuery._data( form, "submit", true );
} }
}); });
// return undefined since we don't need an event listener // return undefined since we don't need an event listener
@ -878,7 +878,7 @@ if ( !support.submitBubbles ) {
} }
// IE change delegation and checkbox/radio fix // IE change delegation and checkbox/radio fix
if ( !support.changeBubbles ) { if ( !support.change ) {
jQuery.event.special.change = { jQuery.event.special.change = {
@ -908,13 +908,13 @@ if ( !support.changeBubbles ) {
jQuery.event.add( this, "beforeactivate._change", function( e ) { jQuery.event.add( this, "beforeactivate._change", function( e ) {
var elem = e.target; 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 ) { jQuery.event.add( elem, "change._change", function( event ) {
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
jQuery.event.simulate( "change", this.parentNode, event, true ); 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 // Support: Firefox
if ( !support.focusinBubbles ) { // 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 ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout // Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) { 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 ] = { jQuery.event.special[ fix ] = {
setup: function() { setup: function() {

View File

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