aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2013-09-17 18:51:54 -0400
committerDave Methvin <dave.methvin@gmail.com>2013-10-22 22:03:20 -0400
commit9b6f0745805941a6d7b7c16c02cf56ab00021c82 (patch)
tree7b3329a0d1d739481ef1776986b872653c00093d /src
parent083edd60a6c189f17ff1087431e849dd11c111b2 (diff)
downloadjquery-9b6f0745805941a6d7b7c16c02cf56ab00021c82.tar.gz
jquery-9b6f0745805941a6d7b7c16c02cf56ab00021c82.zip
Fix #14180. Allow cross-frame use of focusin/out. Close gh-1369.
Diffstat (limited to 'src')
-rw-r--r--src/event.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/event.js b/src/event.js
index 2fd702c63..ce5b453d2 100644
--- a/src/event.js
+++ b/src/event.js
@@ -727,22 +727,29 @@ jQuery.each({
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 = data_priv.access( doc, "focusCount" );
+
+ if ( !attaches ) {
+ doc.addEventListener( orig, handler, true );
}
+ data_priv.access( doc, "focusCount", ( attaches || 0 ) + 1 );
},
teardown: function() {
- if ( --attaches === 0 ) {
- document.removeEventListener( orig, handler, true );
+ var doc = this.ownerDocument,
+ attaches = data_priv.access( doc, "focusCount" ) - 1;
+
+ if ( !attaches ) {
+ doc.removeEventListener( orig, handler, true );
}
+ data_priv.access( doc, "focusCount", attaches );
}
};
});