This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22< div ng-controller ="DropdownCtrl ">
33 <!-- Simple dropdown -->
44 < span class ="dropdown " on-toggle ="toggled(open) ">
5- < a class ="dropdown-toggle ">
5+ < a href class ="dropdown-toggle ">
66 Click me for a dropdown, yo!
77 </ a >
88 < ul class ="dropdown-menu ">
99 < li ng-repeat ="choice in items ">
10- < a > {{choice}}</ a >
10+ < a href > {{choice}}</ a >
1111 </ li >
1212 </ ul >
1313 </ span >
Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ angular.module('ui.bootstrap.dropdown', [])
5353 return $scope . isOpen = arguments . length ? ! ! open : ! $scope . isOpen ;
5454 } ;
5555
56+ // Allow other directives to watch status
57+ this . isOpen = function ( ) {
58+ return $scope . isOpen ;
59+ } ;
60+
5661 $scope . $watch ( 'isOpen' , function ( value ) {
5762 self . $element . toggleClass ( openClass , value ) ;
5863
@@ -103,6 +108,12 @@ angular.module('ui.bootstrap.dropdown', [])
103108 } ) ;
104109 }
105110 } ) ;
111+
112+ // WAI-ARIA
113+ element . attr ( { 'aria-haspopup' : true , 'aria-expanded' : false } ) ;
114+ scope . $watch ( dropdownCtrl . isOpen , function ( isOpen ) {
115+ element . attr ( 'aria-expanded' , ! ! isOpen ) ;
116+ } ) ;
106117 }
107118 } ;
108119} ) ;
Original file line number Diff line number Diff line change @@ -106,6 +106,18 @@ describe('dropdownToggle', function() {
106106 checkboxEl . click ( ) ;
107107 expect ( $rootScope . clicked ) . toBeTruthy ( ) ;
108108 } ) ;
109+
110+ // WAI-ARIA
111+ it ( 'should aria markup to the `dropdown-toggle`' , function ( ) {
112+ var toggleEl = element . find ( 'a' ) ;
113+ expect ( toggleEl . attr ( 'aria-haspopup' ) ) . toBe ( 'true' ) ;
114+ expect ( toggleEl . attr ( 'aria-expanded' ) ) . toBe ( 'false' ) ;
115+
116+ clickDropdownToggle ( ) ;
117+ expect ( toggleEl . attr ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
118+ clickDropdownToggle ( ) ;
119+ expect ( toggleEl . attr ( 'aria-expanded' ) ) . toBe ( 'false' ) ;
120+ } ) ;
109121 } ) ;
110122
111123 describe ( 'without trigger' , function ( ) {
You can’t perform that action at this time.
0 commit comments