0
|
1 define( [
|
|
2 "../core",
|
|
3 "../data/var/dataPriv",
|
|
4 "./support",
|
|
5
|
|
6 "../event",
|
|
7 "./trigger"
|
|
8 ], function( jQuery, dataPriv, support ) {
|
|
9
|
|
10 "use strict";
|
|
11
|
|
12 // Support: Firefox <=44
|
|
13 // Firefox doesn't have focus(in | out) events
|
|
14 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
|
|
15 //
|
|
16 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
|
|
17 // focus(in | out) events fire after focus & blur events,
|
|
18 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
|
|
19 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
|
|
20 if ( !support.focusin ) {
|
|
21 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
|
22
|
|
23 // Attach a single capturing handler on the document while someone wants focusin/focusout
|
|
24 var handler = function( event ) {
|
|
25 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
|
|
26 };
|
|
27
|
|
28 jQuery.event.special[ fix ] = {
|
|
29 setup: function() {
|
|
30 var doc = this.ownerDocument || this,
|
|
31 attaches = dataPriv.access( doc, fix );
|
|
32
|
|
33 if ( !attaches ) {
|
|
34 doc.addEventListener( orig, handler, true );
|
|
35 }
|
|
36 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
|
|
37 },
|
|
38 teardown: function() {
|
|
39 var doc = this.ownerDocument || this,
|
|
40 attaches = dataPriv.access( doc, fix ) - 1;
|
|
41
|
|
42 if ( !attaches ) {
|
|
43 doc.removeEventListener( orig, handler, true );
|
|
44 dataPriv.remove( doc, fix );
|
|
45
|
|
46 } else {
|
|
47 dataPriv.access( doc, fix, attaches );
|
|
48 }
|
|
49 }
|
|
50 };
|
|
51 } );
|
|
52 }
|
|
53
|
|
54 return jQuery;
|
|
55 } );
|