aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-12-06 18:02:58 -0800
committerJohn Resig <jeresig@gmail.com>2009-12-06 18:02:58 -0800
commit542099a278e79dce38e814e7e7b448a1b73df82f (patch)
treea0ab68bffdeb3731af4ad9391b248ca6dfccc9a7
parent19ad49e607e91919210a766e17f67f0fc6af7af1 (diff)
downloadjquery-542099a278e79dce38e814e7e7b448a1b73df82f.tar.gz
jquery-542099a278e79dce38e814e7e7b448a1b73df82f.zip
Make sure that we're doing proper focus bubble testing. Also simplified the logic for the IE focusin/focusout handling.
-rw-r--r--src/event.js38
-rw-r--r--src/support.js1
2 files changed, 15 insertions, 24 deletions
diff --git a/src/event.js b/src/event.js
index d9401c99e..c2d74763c 100644
--- a/src/event.js
+++ b/src/event.js
@@ -674,36 +674,26 @@ function trigger( type, elem, args ) {
}
// Create "bubbling" focus and blur events
-jQuery.each({
- focus: "focusin",
- blur: "focusout"
-}, function( orig, fix ){
- var event = jQuery.event,
- handle = event.handle;
-
- function ieHandler() {
- arguments[0].type = orig;
- return handle.apply(this, arguments);
- }
+if ( !jQuery.support.focusBubbles ) {
- event.special[orig] = {
- setup:function() {
- if ( this.addEventListener ) {
- this.addEventListener( orig, handle, true );
- } else {
- event.add( this, fix, ieHandler );
- }
+jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ){
+ event.special[ orig ] = {
+ setup: function() {
+ jQuery.event.add( this, fix, ieHandler );
},
- teardown:function() {
- if ( this.removeEventListener ) {
- this.removeEventListener( orig, handle, true );
- } else {
- event.remove( this, fix, ieHandler );
- }
+ teardown: function() {
+ jQuery.event.remove( this, fix, ieHandler );
}
};
+
+ function ieHandler() {
+ arguments[0].type = orig;
+ return jQuery.event.handle.apply(this, arguments);
+ }
});
+}
+
jQuery.fn.extend({
// TODO: make bind(), unbind() and one() DRY!
bind: function( type, data, fn, thisObject ) {
diff --git a/src/support.js b/src/support.js
index ad8566d8b..9d5558f39 100644
--- a/src/support.js
+++ b/src/support.js
@@ -109,6 +109,7 @@
jQuery.support.submitBubbles = eventSupported("submit");
jQuery.support.changeBubbles = eventSupported("change");
+ jQuery.support.focusBubbles = eventSupported("focus");
// release memory in IE
root = script = div = all = a = null;