diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2013-09-17 18:51:54 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2013-11-12 21:24:20 -0500 |
commit | 97d53838e00f27d7dcf51f6a5627d8675f998284 (patch) | |
tree | 84c1119c20892199e8870d8a7bee3965b8d5b09c /src | |
parent | 60a6178131afec97b68c9a45bc24459f7b8bd905 (diff) | |
download | jquery-97d53838e00f27d7dcf51f6a5627d8675f998284.tar.gz jquery-97d53838e00f27d7dcf51f6a5627d8675f998284.zip |
Fix #14180. Allow cross-frame use of focusin/out. Close gh-1369.
(cherry picked from commit ebdb467761d756d4e52608a0df4a4d9b17da8092)
(conflicts with .data() resolved manually)
Diffstat (limited to 'src')
-rw-r--r-- | src/event.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/event.js b/src/event.js index 2ca50aba4..3f19bab30 100644 --- a/src/event.js +++ b/src/event.js @@ -892,21 +892,30 @@ if ( !support.changeBubbles ) { if ( !support.focusinBubbles ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0, - handler = function( event ) { + // 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.special[ fix ] = { setup: function() { - if ( attaches++ === 0 ) { - document.addEventListener( orig, handler, true ); + var doc = this.ownerDocument, + attaches = jQuery._data( doc, fix ); + + if ( !attaches ) { + doc.addEventListener( orig, handler, true ); } + jQuery._data( doc, fix, ( attaches || 0 ) + 1 ); }, teardown: function() { - if ( --attaches === 0 ) { - document.removeEventListener( orig, handler, true ); + var doc = this.ownerDocument, + attaches = jQuery._data( doc, fix ) - 1; + + if ( !attaches ) { + doc.removeEventListener( orig, handler, true ); + jQuery._removeData( doc, fix ); + } else { + jQuery._data( doc, fix, attaches ); } } }; |