}
// 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) {
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;
<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