File tree 2 files changed +32
-3
lines changed
2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,23 @@ var Status = (function () {
2
2
'use strict' ;
3
3
4
4
function Status ( options ) {
5
- this . el = '<span role="status" aria-live="polite" class="visuallyhidden"></span>' ;
6
- this . $el = $ ( this . el ) ;
5
+ this . $el = $ ( '<span></span>' , {
6
+ 'role' : 'status' ,
7
+ 'aria-live' : 'polite' ,
8
+ } ) . css ( {
9
+ // This `.visuallyhidden` style is inspired by HTML5 Boilerplate
10
+ // https://github.com/h5bp/html5-boilerplate/blob/fea7f22/src/css/main.css#L128
11
+ 'position' : 'absolute' ,
12
+ 'padding' : '0' ,
13
+ 'border' : '0' ,
14
+ 'height' : '1px' ,
15
+ 'width' : '1px' ,
16
+ 'margin-bottom' : '-1px' ,
17
+ 'margin-right' : '-1px' ,
18
+ 'overflow' : 'hidden' ,
19
+ 'clip' : 'rect(0 0 0 0)' ,
20
+ 'white-space' : 'nowrap' ,
21
+ } ) ;
7
22
options . $input . after ( this . $el ) ;
8
23
_ . each ( options . menu . datasets , _ . bind ( function ( dataset ) {
9
24
if ( dataset . onSync ) {
Original file line number Diff line number Diff line change @@ -25,10 +25,24 @@ describe('Status', function() {
25
25
} ) ;
26
26
27
27
it ( 'renders a status element after the input' , function ( ) {
28
- expect ( status . el ) . toEqual ( '<span role="status" aria-live="polite" class="visuallyhidden"></span>' ) ;
28
+ expect ( status . $el . attr ( 'role' ) ) . toEqual ( 'status' ) ;
29
+ expect ( status . $el . attr ( 'aria-live' ) ) . toEqual ( 'polite' ) ;
29
30
expect ( status . $el . prev ( ) ) . toEqual ( this . $input ) ;
30
31
} ) ;
31
32
33
+ it ( 'renders a status element that is visible to screen readers' , function ( ) {
34
+ expect ( status . $el . attr ( 'aria-hidden' ) ) . not . toEqual ( 'true' ) ;
35
+ expect ( status . $el . css ( 'display' ) ) . not . toEqual ( 'none' ) ;
36
+ expect ( status . $el . css ( 'visibility' ) ) . not . toEqual ( 'hidden' ) ;
37
+ expect ( status . $el . height ( ) ) . not . toEqual ( 0 ) ;
38
+ expect ( status . $el . width ( ) ) . not . toEqual ( 0 ) ;
39
+ } ) ;
40
+
41
+ it ( 'renders a status element that is hidden on displays' , function ( ) {
42
+ expect ( status . $el . outerHeight ( true ) ) . toEqual ( 0 ) ;
43
+ expect ( status . $el . outerWidth ( true ) ) . toEqual ( 0 ) ;
44
+ } ) ;
45
+
32
46
describe ( 'when rendered is triggered on the datasets' , function ( ) {
33
47
34
48
it ( 'should update the status text based on number of suggestion' , function ( ) {
You can’t perform that action at this time.
0 commit comments