This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 2 files changed +28
-2
lines changed
2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,11 @@ angular.module('ui.bootstrap.collapse', [])
5
5
return {
6
6
link : function ( scope , element , attrs ) {
7
7
function expand ( ) {
8
- element . removeClass ( 'collapse' ) . addClass ( 'collapsing' ) ;
8
+ element . removeClass ( 'collapse' )
9
+ . addClass ( 'collapsing' )
10
+ . attr ( 'aria-expanded' , true )
11
+ . attr ( 'aria-hidden' , false ) ;
12
+
9
13
$animate . addClass ( element , 'in' , {
10
14
to : { height : element [ 0 ] . scrollHeight + 'px' }
11
15
} ) . then ( expandDone ) ;
@@ -29,7 +33,9 @@ angular.module('ui.bootstrap.collapse', [])
29
33
// initially all panel collapse have the collapse class, this removal
30
34
// prevents the animation from jumping to collapsed state
31
35
. removeClass ( 'collapse' )
32
- . addClass ( 'collapsing' ) ;
36
+ . addClass ( 'collapsing' )
37
+ . attr ( 'aria-expanded' , false )
38
+ . attr ( 'aria-hidden' , true ) ;
33
39
34
40
$animate . removeClass ( element , 'in' , {
35
41
to : { height : '0' }
Original file line number Diff line number Diff line change @@ -70,6 +70,26 @@ describe('collapse directive', function () {
70
70
expect ( element . height ( ) ) . toBe ( 0 ) ;
71
71
} ) ;
72
72
73
+ it ( 'should change aria-expanded attribute' , function ( ) {
74
+ scope . isCollapsed = false ;
75
+ scope . $digest ( ) ;
76
+ expect ( element . attr ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
77
+
78
+ scope . isCollapsed = true ;
79
+ scope . $digest ( ) ;
80
+ expect ( element . attr ( 'aria-expanded' ) ) . toBe ( 'false' ) ;
81
+ } ) ;
82
+
83
+ it ( 'should change aria-hidden attribute' , function ( ) {
84
+ scope . isCollapsed = false ;
85
+ scope . $digest ( ) ;
86
+ expect ( element . attr ( 'aria-hidden' ) ) . toBe ( 'false' ) ;
87
+
88
+ scope . isCollapsed = true ;
89
+ scope . $digest ( ) ;
90
+ expect ( element . attr ( 'aria-hidden' ) ) . toBe ( 'true' ) ;
91
+ } ) ;
92
+
73
93
describe ( 'dynamic content' , function ( ) {
74
94
75
95
var element ;
You can’t perform that action at this time.
0 commit comments