This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 3 files changed +25
-2
lines changed
3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 2
2
< div ng-controller ="DropdownCtrl ">
3
3
<!-- Simple dropdown -->
4
4
< span class ="dropdown " on-toggle ="toggled(open) ">
5
- < a class ="dropdown-toggle ">
5
+ < a href class ="dropdown-toggle ">
6
6
Click me for a dropdown, yo!
7
7
</ a >
8
8
< ul class ="dropdown-menu ">
9
9
< li ng-repeat ="choice in items ">
10
- < a > {{choice}}</ a >
10
+ < a href > {{choice}}</ a >
11
11
</ li >
12
12
</ ul >
13
13
</ span >
Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ angular.module('ui.bootstrap.dropdown', [])
53
53
return $scope . isOpen = arguments . length ? ! ! open : ! $scope . isOpen ;
54
54
} ;
55
55
56
+ // Allow other directives to watch status
57
+ this . isOpen = function ( ) {
58
+ return $scope . isOpen ;
59
+ } ;
60
+
56
61
$scope . $watch ( 'isOpen' , function ( value ) {
57
62
self . $element . toggleClass ( openClass , value ) ;
58
63
@@ -103,6 +108,12 @@ angular.module('ui.bootstrap.dropdown', [])
103
108
} ) ;
104
109
}
105
110
} ) ;
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
+ } ) ;
106
117
}
107
118
} ;
108
119
} ) ;
Original file line number Diff line number Diff line change @@ -106,6 +106,18 @@ describe('dropdownToggle', function() {
106
106
checkboxEl . click ( ) ;
107
107
expect ( $rootScope . clicked ) . toBeTruthy ( ) ;
108
108
} ) ;
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
+ } ) ;
109
121
} ) ;
110
122
111
123
describe ( 'without trigger' , function ( ) {
You can’t perform that action at this time.
0 commit comments