r89878 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89877‎ | r89878 | r89879 >
Date:10:56, 11 June 2011
Author:krinkle
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.tabIndex.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.tabIndex.js
@@ -9,12 +9,14 @@
1010 */
1111 $.fn.firstTabIndex = function() {
1212 var minTabIndex = null;
13 - $(this).find( '[tabindex]' ).each( function( i ) {
 13+ $(this).find( '[tabindex]' ).each( function() {
1414 var tabIndex = parseInt( $(this).attr( 'tabindex' ), 10 );
1515 // In IE6/IE7 the above jQuery selector returns all elements,
1616 // becuase it has a default value for tabIndex in IE6/IE7 of 0
17 - // (rather than null/undefined). Therefore check "> 0" as well
18 - if ( tabIndex > 0 ) {
 17+ // (rather than null/undefined). Therefore check "> 0" as well.
 18+ // Under IE7 under Windows NT 5.2 is also capable of returning NaN.
 19+ if ( tabIndex > 0 && !isNaN( tabIndex ) ) {
 20+ // Initial value
1921 if ( minTabIndex === null ) {
2022 minTabIndex = tabIndex;
2123 } else if ( tabIndex < minTabIndex ) {
@@ -32,12 +34,15 @@
3335 */
3436 $.fn.lastTabIndex = function() {
3537 var maxTabIndex = null;
36 - $(this).find( '[tabindex]' ).each( function( i ) {
 38+ $(this).find( '[tabindex]' ).each( function() {
3739 var tabIndex = parseInt( $(this).attr( 'tabindex' ), 10 );
38 - if ( maxTabIndex === null ) {
39 - maxTabIndex = tabIndex;
40 - } else if ( tabIndex > maxTabIndex ) {
41 - maxTabIndex = tabIndex;
 40+ if ( tabIndex > 0 && !isNaN( tabIndex ) ) {
 41+ // Initial value
 42+ if ( maxTabIndex === null ) {
 43+ maxTabIndex = tabIndex;
 44+ } else if ( tabIndex > maxTabIndex ) {
 45+ maxTabIndex = tabIndex;
 46+ }
4247 }
4348 } );
4449 return maxTabIndex;

Status & tagging log