aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
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-11-12 21:15:08 -0500
commit1cecf64e5aa415367a7dae0b55c2dd17b591442d (patch)
tree86dec4b0af8ab539eb65c7e806098ce4527380a6 /src/event.js
parentb7f62abb87dd200129fb2a781d008fc19d26115a (diff)
downloadjquery-1cecf64e5aa415367a7dae0b55c2dd17b591442d.tar.gz
jquery-1cecf64e5aa415367a7dae0b55c2dd17b591442d.zip
Fix #14180. Allow cross-frame use of focusin/out. Close gh-1369.
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/event.js b/src/event.js
index ec905f2d6..fc924ec36 100644
--- a/src/event.js
+++ b/src/event.js
@@ -726,21 +726,31 @@ 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, fix );
+
+ if ( !attaches ) {
+ doc.addEventListener( orig, handler, true );
}
+ data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
},
teardown: function() {
- if ( --attaches === 0 ) {
- document.removeEventListener( orig, handler, true );
+ var doc = this.ownerDocument,
+ attaches = data_priv.access( doc, fix ) - 1;
+
+ if ( !attaches ) {
+ doc.removeEventListener( orig, handler, true );
+ data_priv.remove( doc, fix );
+
+ } else {
+ data_priv.access( doc, fix, attaches );
}
}
};