From: Krinkle Date: Sat, 11 Jun 2011 10:56:54 +0000 (+0000) Subject: Fix jquery.tabIndex even more. X-Git-Tag: 1.31.0-rc.0~29572 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=24a4d0309b892508e8beec5a587dbb8bf8294f73;p=lhc%2Fweb%2Fwiklou.git Fix jquery.tabIndex even more. * Discovered through TestSwarm. Aside from IE6/IE7, which already needed extra checking, when IE6/IE7 is on Windows NT 5.2, it can also return NaN. --- diff --git a/resources/jquery/jquery.tabIndex.js b/resources/jquery/jquery.tabIndex.js index 4c406772a4..33e0604723 100644 --- a/resources/jquery/jquery.tabIndex.js +++ b/resources/jquery/jquery.tabIndex.js @@ -9,12 +9,14 @@ */ $.fn.firstTabIndex = function() { var minTabIndex = null; - $(this).find( '[tabindex]' ).each( function( i ) { + $(this).find( '[tabindex]' ).each( function() { var tabIndex = parseInt( $(this).attr( 'tabindex' ), 10 ); // In IE6/IE7 the above jQuery selector returns all elements, // becuase it has a default value for tabIndex in IE6/IE7 of 0 - // (rather than null/undefined). Therefore check "> 0" as well - if ( tabIndex > 0 ) { + // (rather than null/undefined). Therefore check "> 0" as well. + // Under IE7 under Windows NT 5.2 is also capable of returning NaN. + if ( tabIndex > 0 && !isNaN( tabIndex ) ) { + // Initial value if ( minTabIndex === null ) { minTabIndex = tabIndex; } else if ( tabIndex < minTabIndex ) { @@ -32,12 +34,15 @@ $.fn.firstTabIndex = function() { */ $.fn.lastTabIndex = function() { var maxTabIndex = null; - $(this).find( '[tabindex]' ).each( function( i ) { + $(this).find( '[tabindex]' ).each( function() { var tabIndex = parseInt( $(this).attr( 'tabindex' ), 10 ); - if ( maxTabIndex === null ) { - maxTabIndex = tabIndex; - } else if ( tabIndex > maxTabIndex ) { - maxTabIndex = tabIndex; + if ( tabIndex > 0 && !isNaN( tabIndex ) ) { + // Initial value + if ( maxTabIndex === null ) { + maxTabIndex = tabIndex; + } else if ( tabIndex > maxTabIndex ) { + maxTabIndex = tabIndex; + } } } ); return maxTabIndex;