]> source.dussan.org Git - jquery.git/commitdiff
Fixed tabindex normalization so that elements that natively support tabbing, but...
authorScott González <scott.gonzalez@gmail.com>
Wed, 7 Jan 2009 14:36:30 +0000 (14:36 +0000)
committerScott González <scott.gonzalez@gmail.com>
Wed, 7 Jan 2009 14:36:30 +0000 (14:36 +0000)
Removed jQuery.support.tabindex since we're only normalizing non-XML right now and all browsers support tabIndex for HTML documents.

src/core.js
src/support.js
test/unit/core.js

index c4c3867175a7980b9c00033704aec1f9b2f68427..61a9bd9f6a406f352ba5310162ea82b121d9d8cf 100644 (file)
@@ -968,11 +968,15 @@ jQuery.extend({
                                if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )
                                        return elem.getAttributeNode( name ).nodeValue;
 
-                               // elem.tabindex doesn't always return the correct value
+                               // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
                                // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
-                               if ( name == jQuery.props.tabindex ) {
-                                       var attributeNode = elem.getAttributeNode(jQuery.props.tabindex);
-                                       return attributeNode && attributeNode.specified && attributeNode.value || undefined;
+                               if ( name == "tabIndex" ) {
+                                       var attributeNode = elem.getAttributeNode( "tabIndex" );
+                                       return attributeNode && attributeNode.specified
+                                               ? attributeNode.value
+                                               : elem.nodeName.match(/^(a|area|button|input|object|select|textarea)$/i)
+                                                       ? 0
+                                                       : undefined;
                                }
 
                                return elem[ name ];
index c334e78d600cd113609cc32da7e06e2f2bdc4fc2..bacc5bd4ec7d2b91284169a79c8b3ed8b65d0a51 100644 (file)
                // (IE uses styleFloat instead of cssFloat)
                cssFloat: !!a.style.cssFloat,
 
-               // Verify tabindex attribute existence
-               // (IE uses tabIndex instead of tabindex)
-               tabindex: !a.getAttributeNode('tabindex'),
-
                // Will be defined later
                scriptEval: false,
                noCloneEvent: true
@@ -101,5 +97,5 @@ jQuery.props = {
        maxlength: "maxLength",
        cellspacing: "cellSpacing",
        rowspan: "rowSpan",
-       tabindex: jQuery.support.tabindex ? "tabindex" : "tabIndex"
+       tabindex: "tabIndex"
 };
index e1c373301b3098118b5ff5eaa349d2058596cb11..ee5f805ec5fc10d1e0431ea00ad982bb5b2ede0f 100644 (file)
@@ -562,7 +562,7 @@ test("attr('tabindex')", function() {
        equals(jQuery('#divWithNoTabIndex').attr('tabindex'), undefined, 'no tabindex, not tabbable by default');
 
     // link without a tabindex
-       equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), undefined, 'no tabindex, tabbable by default');
+       equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), 0, 'no tabindex, tabbable by default');
 });
 
 test("attr('tabindex', value)", function() {
@@ -1560,7 +1560,7 @@ test("removeClass(String) - simple", function() {
 });
 
 test("toggleClass(String)", function() {
-       expect(6);\r
+       expect(6);
        var e = jQuery("#firstp");
        ok( !e.is(".test"), "Assert class not present" );
        e.toggleClass("test");
@@ -1568,12 +1568,12 @@ test("toggleClass(String)", function() {
        e.toggleClass("test");
        ok( !e.is(".test"), "Assert class not present" );
 
-       e.toggleClass("test", false);\r
-       ok( !e.is(".test"), "Assert class not present" );\r
-       e.toggleClass("test", true);\r
-       ok( e.is(".test"), "Assert class present" );\r
-       e.toggleClass("test", false);\r
-       ok( !e.is(".test"), "Assert class not present" );\r
+       e.toggleClass("test", false);
+       ok( !e.is(".test"), "Assert class not present" );
+       e.toggleClass("test", true);
+       ok( e.is(".test"), "Assert class present" );
+       e.toggleClass("test", false);
+       ok( !e.is(".test"), "Assert class not present" );
 });
 
 test("removeAttr(String", function() {