aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJustin Meyer <justinbmeyer@gmail.com>2010-10-13 10:35:28 -0400
committerjeresig <jeresig@gmail.com>2010-10-13 10:35:28 -0400
commit88068f82c199847d3679b130664dd91cc2e89f00 (patch)
treef5fc1462ace80caed2e7cbaa05545b0e61d05d08 /src
parent39addc87a37b32be19f2c58ec8babe752c0243e1 (diff)
downloadjquery-88068f82c199847d3679b130664dd91cc2e89f00.tar.gz
jquery-88068f82c199847d3679b130664dd91cc2e89f00.zip
Make sure that focusin/focusout bubbles in non-IE browsers.
Diffstat (limited to 'src')
-rw-r--r--src/event.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/event.js b/src/event.js
index ab7567081..d830c4d98 100644
--- a/src/event.js
+++ b/src/event.js
@@ -7,7 +7,8 @@ var rnamespaces = /\.(.*)$/,
rescape = /[^\w\s.|`]/g,
fcleanup = function( nm ) {
return nm.replace(rescape, "\\$&");
- };
+ },
+ focusCounts = { focusin: 0, focusout: 0 };
/*
* A number of helper functions used for managing events.
@@ -855,17 +856,21 @@ if ( document.addEventListener ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
jQuery.event.special[ fix ] = {
setup: function() {
- this.addEventListener( orig, handler, true );
+ if ( focusCounts[fix]++ === 0 ) {
+ document.addEventListener( orig, handler, true );
+ }
},
teardown: function() {
- this.removeEventListener( orig, handler, true );
+ if ( --focusCounts[fix] === 0 ) {
+ document.removeEventListener( orig, handler, true );
+ }
}
};
function handler( e ) {
e = jQuery.event.fix( e );
e.type = fix;
- return jQuery.event.handle.call( this, e );
+ return jQuery.event.trigger( e, null, e.target );
}
});
}