]> source.dussan.org Git - jquery-ui.git/commitdiff
Accordion: set aria-selected to true on selected header, false on others. Fixed ...
authorRichard Worth <rdworth@gmail.com>
Tue, 15 Mar 2011 08:30:36 +0000 (04:30 -0400)
committerRichard Worth <rdworth@gmail.com>
Tue, 15 Mar 2011 08:30:36 +0000 (04:30 -0400)
tests/unit/accordion/accordion_core.js
ui/jquery.ui.accordion.js

index 24dc0146be737d3b6880b738492dad75b1851573..26395985185c12e3b3b308f8a712175835c9477c 100644 (file)
@@ -28,7 +28,7 @@ test( "ui-accordion-heading class added to headers anchor", function() {
 });
 
 test( "accessibility", function () {
-       expect( 9 );
+       expect( 13 );
        var ac = $( "#list1" ).accordion().accordion( "option", "active", 1 );
        var headers = $( ".ui-accordion-header" );
 
@@ -39,9 +39,13 @@ test( "accessibility", function () {
        equals( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
        equals( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
        equals( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
+       equals( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
+       equals( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
        ac.accordion( "option", "active", 0 );
        equals( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
        equals( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
+       equals( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
+       equals( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
 });
 
 }( jQuery ) );
index 34327be279ede23bd3557b01557da9e852c51ac1..7f67814b428590c62c82c0c7282abef2c0d45b96 100644 (file)
@@ -75,6 +75,7 @@ $.widget( "ui.accordion", {
                        .not( self.active )
                        .attr({
                                "aria-expanded": "false",
+                               "aria-selected": "false",
                                tabIndex: -1
                        })
                        .next()
@@ -87,6 +88,7 @@ $.widget( "ui.accordion", {
                        self.active
                                .attr({
                                        "aria-expanded": "true",
+                                       "aria-selected": "true",
                                        tabIndex: 0
                                });
                }
@@ -129,6 +131,7 @@ $.widget( "ui.accordion", {
                        .removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
                        .removeAttr( "role" )
                        .removeAttr( "aria-expanded" )
+                       .removeAttr( "aria-selected" )
                        .removeAttr( "tabIndex" )
                        .find( "a" )
                                .removeAttr( "tabIndex" )
@@ -387,12 +390,14 @@ $.widget( "ui.accordion", {
                toHide.prev()
                        .attr({
                                "aria-expanded": "false",
+                               "aria-selected": "false",
                                tabIndex: -1
                        })
                        .blur();
                toShow.prev()
                        .attr({
                                "aria-expanded": "true",
+                               "aria-selected": "true",
                                tabIndex: 0
                        })
                        .focus();