]> source.dussan.org Git - jquery.git/commitdiff
Make sure that we're doing proper focus bubble testing. Also simplified the logic...
authorJohn Resig <jeresig@gmail.com>
Mon, 7 Dec 2009 02:02:58 +0000 (18:02 -0800)
committerJohn Resig <jeresig@gmail.com>
Mon, 7 Dec 2009 02:02:58 +0000 (18:02 -0800)
src/event.js
src/support.js

index d9401c99e743ff58c650cf4e57aeb83bad5f27aa..c2d74763cb673ea133c2ffa92074b92012a71942 100644 (file)
@@ -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 ) {
index ad8566d8bd047ab106d5f5d4b48bb3f9636c0f1f..9d5558f396a81864b269e0fd8d76b0c326833ed4 100644 (file)
        
        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;