Skip to content

Commit

Permalink
Event: provide verbose info for focus(in | out) & rename support props
Browse files Browse the repository at this point in the history
  • Loading branch information
markelog committed May 19, 2015
1 parent 8d88cd5 commit 401a351
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 46 deletions.
27 changes: 17 additions & 10 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ jQuery.each({
});

// IE submit delegation
if ( !support.submitBubbles ) {
if ( !support.submit ) {

jQuery.event.special.submit = {
setup: function() {
Expand All @@ -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
Expand Down Expand Up @@ -878,7 +878,7 @@ if ( !support.submitBubbles ) {
}

// IE change delegation and checkbox/radio fix
if ( !support.changeBubbles ) {
if ( !support.change ) {

jQuery.event.special.change = {

Expand Down Expand Up @@ -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 );
}
});
},
Expand All @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions src/event/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
66 changes: 33 additions & 33 deletions test/unit/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ 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,
"cors": true,
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -100,22 +100,22 @@ 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,
"cors": true,
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": true,
"focusin": true,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -132,22 +132,22 @@ 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,
"cors": false,
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": true,
"focusin": true,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -164,22 +164,22 @@ 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,
"cors": false,
"createHTMLDocument": false,
"cssFloat": false,
"deleteExpando": false,
"focusinBubbles": true,
"focusin": true,
"html5Clone": false,
"htmlSerialize": false,
"input": false,
Expand All @@ -196,22 +196,22 @@ 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,
"cors": true,
"createHTMLDocument": false,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -228,22 +228,22 @@ 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,
"cors": true,
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -260,22 +260,22 @@ 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,
"cors": true,
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -292,22 +292,22 @@ 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,
"cors": true,
"createHTMLDocument": false,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -324,22 +324,22 @@ 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,
"cors": true,
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -356,22 +356,22 @@ 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,
"cors": true,
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -388,22 +388,22 @@ 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,
"cors": true,
"createHTMLDocument": true,
"cssFloat": true,
"deleteExpando": true,
"focusinBubbles": false,
"focusin": false,
"html5Clone": true,
"htmlSerialize": true,
"input": true,
Expand All @@ -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
};
}

Expand Down

0 comments on commit 401a351

Please sign in to comment.