-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Event: Separate trigger/simulate into its own module
Fixes gh-1864 Closes gh-2692 This also pulls the focusin/out special event into its own module, since that depends on simulate(). NB: The ajax module triggers events pretty heavily.
- Loading branch information
Showing
7 changed files
with
261 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
define( [ | ||
"../core", | ||
"../data/var/dataPriv", | ||
"./support", | ||
|
||
"../event", | ||
"./trigger" | ||
], function( jQuery, dataPriv, support ) { | ||
|
||
// 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 ) ); | ||
}; | ||
|
||
jQuery.event.special[ fix ] = { | ||
setup: function() { | ||
var doc = this.ownerDocument || this, | ||
attaches = dataPriv.access( doc, fix ); | ||
|
||
if ( !attaches ) { | ||
doc.addEventListener( orig, handler, true ); | ||
} | ||
dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); | ||
}, | ||
teardown: function() { | ||
var doc = this.ownerDocument || this, | ||
attaches = dataPriv.access( doc, fix ) - 1; | ||
|
||
if ( !attaches ) { | ||
doc.removeEventListener( orig, handler, true ); | ||
dataPriv.remove( doc, fix ); | ||
|
||
} else { | ||
dataPriv.access( doc, fix, attaches ); | ||
} | ||
} | ||
}; | ||
} ); | ||
} | ||
|
||
return jQuery; | ||
} ); |
Oops, something went wrong.