]> source.dussan.org Git - jquery.git/commitdiff
Stop trying to emulate the focus/blur event in IE, doesn't work as one might expect...
authorJörn Zaefferer <joern.zaefferer@googlemail.com>
Mon, 21 Dec 2009 21:10:21 +0000 (16:10 -0500)
committerjeresig <jeresig@gmail.com>
Mon, 21 Dec 2009 21:10:21 +0000 (16:10 -0500)
src/event.js
src/support.js
test/delegatetest.html

index 983e9e52f331ba25d515ff2c768336ef3ea4f18f..3d2be68ce0a84d483d996dec8274f35964d9af74 100644 (file)
@@ -720,24 +720,23 @@ function trigger( type, elem, args ) {
 }
 
 // Create "bubbling" focus and blur events
-if ( !jQuery.support.focusBubbles ) {
+if ( document.addEventListener ) {
+       jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ){
+               jQuery.event.special[ fix ] = {
+                       setup: function() {
+                               this.addEventListener( orig, handler, true );
+                       }, 
+                       teardown: function() { 
+                               this.removeEventListener( orig, handler, true );
+                       }
+               };
 
-jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ){
-       jQuery.event.special[ orig ] = {
-               setup: function() {
-                       jQuery.event.add( this, fix, ieHandler );
-               }, 
-               teardown: function() { 
-                       jQuery.event.remove( this, fix, ieHandler );
+               function handler( e ) { 
+                       e = jQuery.event.fix( e );
+                       e.type = fix;
+                       return jQuery.event.handle.call( this, e );
                }
-       };
-
-       function ieHandler() { 
-               arguments[0].type = orig;
-               return jQuery.event.handle.apply(this, arguments);
-       }
-});
-
+       });
 }
 
 jQuery.each(["bind", "one"], function(i, name) {
index 91ee77d390c4f4789f7b189c08d26c87b929f23c..249fb150970523d71c1b51930f6a480fdfb60805 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;
index e3ebbfc6ec13788599780e7d465ced3c4ca72582..7b35c8e0d614694052911add16f64fa37fa37745 100644 (file)
                <td id='textbind' class="red">TEXT</td>\r
                <td id='textareabind' class="red">TEXTAREA</td>\r
            </tr>\r
+           <tr>\r
+               <td>Focusin:</td>\r
+               <td id='selectfocus' class="red">SELECT</td>\r
+               <td id='mselectfocus' class="red">MULTI</td>\r
+               <td id='checkboxfocus' class="red">CHECKBOX</td>\r
+               <td id='radiofocus' class="red">RADIO</td>\r
+               <td id='textfocus' class="red">TEXT</td>\r
+               <td id='textareafocus' class="red">TEXTAREA</td>\r
+           </tr>\r
+           <tr>\r
+               <td>Focusout:</td>\r
+               <td id='selectblur' class="red">SELECT</td>\r
+               <td id='mselectblur' class="red">MULTI</td>\r
+               <td id='checkboxblur' class="red">CHECKBOX</td>\r
+               <td id='radioblur' class="red">RADIO</td>\r
+               <td id='textblur' class="red">TEXT</td>\r
+               <td id='textareablur' class="red">TEXTAREA</td>\r
+           </tr>\r
         </table>\r
         <h2>Submit Tests</h2>\r
         <table>\r
 \r
         <script type='text/javascript'>\r
        jQuery.fn.addChangeTest = function( id, prevent ) {\r
+               this.bind("focusin", function(){\r
+                       jQuery(id + "focus").blink();\r
+               }).bind("focusout", function(){\r
+                       jQuery(id + "blur").blink();\r
+               });\r
+\r
                return this.bind("change", function(e){\r
                        jQuery(id + "bind").blink();\r
                }).live("change", function(e){\r