@@ -31,25 +31,30 @@ describe('<md-select>', function() {
31
31
} ) ) ;
32
32
33
33
it ( 'should preserve tabindex' , function ( ) {
34
- var select = setupSelect ( 'tabindex="2", ng-model="val"' ) . find ( 'md-select' ) ;
34
+ var select = setupSelect ( 'tabindex="2" ng-model="val"' ) . find ( 'md-select' ) ;
35
35
expect ( select . attr ( 'tabindex' ) ) . toBe ( '2' ) ;
36
36
} ) ;
37
37
38
+ it ( 'should set a tabindex if the element does not have one' , function ( ) {
39
+ var select = setupSelect ( 'ng-model="val"' ) . find ( 'md-select' ) ;
40
+ expect ( select . attr ( 'tabindex' ) ) . toBeDefined ( ) ;
41
+ } ) ;
42
+
38
43
it ( 'supports non-disabled state' , function ( ) {
39
44
var select = setupSelect ( 'ng-model="val"' ) . find ( 'md-select' ) ;
40
45
expect ( select . attr ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
41
46
} ) ;
42
47
43
48
it ( 'supports disabled state' , inject ( function ( $document ) {
44
- var select = setupSelect ( 'disabled="disabled", ng-model="val"' ) . find ( 'md-select' ) ;
49
+ var select = setupSelect ( 'disabled ng-model="val"' ) . find ( 'md-select' ) ;
45
50
openSelect ( select ) ;
46
51
expectSelectClosed ( select ) ;
47
52
expect ( $document . find ( 'md-select-menu' ) . length ) . toBe ( 0 ) ;
48
53
expect ( select . attr ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
49
54
} ) ) ;
50
55
51
56
it ( 'supports passing classes to the container' , inject ( function ( $document ) {
52
- var select = setupSelect ( 'ng-model="val", md-container-class="test"' ) . find ( 'md-select' ) ;
57
+ var select = setupSelect ( 'ng-model="val" md-container-class="test"' ) . find ( 'md-select' ) ;
53
58
openSelect ( select ) ;
54
59
55
60
var container = $document [ 0 ] . querySelector ( '._md-select-menu-container' ) ;
@@ -58,7 +63,7 @@ describe('<md-select>', function() {
58
63
} ) ) ;
59
64
60
65
it ( 'supports passing classes to the container using `data-` attribute prefix' , inject ( function ( $document ) {
61
- var select = setupSelect ( 'ng-model="val", data-md-container-class="test"' ) . find ( 'md-select' ) ;
66
+ var select = setupSelect ( 'ng-model="val" data-md-container-class="test"' ) . find ( 'md-select' ) ;
62
67
openSelect ( select ) ;
63
68
64
69
var container = $document [ 0 ] . querySelector ( '._md-select-menu-container' ) ;
@@ -67,7 +72,7 @@ describe('<md-select>', function() {
67
72
} ) ) ;
68
73
69
74
it ( 'supports passing classes to the container using `x-` attribute prefix' , inject ( function ( $document ) {
70
- var select = setupSelect ( 'ng-model="val", x-md-container-class="test"' ) . find ( 'md-select' ) ;
75
+ var select = setupSelect ( 'ng-model="val" x-md-container-class="test"' ) . find ( 'md-select' ) ;
71
76
openSelect ( select ) ;
72
77
73
78
var container = $document [ 0 ] . querySelector ( '._md-select-menu-container' ) ;
@@ -88,7 +93,7 @@ describe('<md-select>', function() {
88
93
$rootScope . onClose = function ( ) {
89
94
called = true ;
90
95
} ;
91
- var select = setupSelect ( 'ng-model="val", md-on-close="onClose()"' , [ 1 , 2 , 3 ] ) . find ( 'md-select' ) ;
96
+ var select = setupSelect ( 'ng-model="val" md-on-close="onClose()"' , [ 1 , 2 , 3 ] ) . find ( 'md-select' ) ;
92
97
openSelect ( select ) ;
93
98
expectSelectOpen ( select ) ;
94
99
@@ -153,7 +158,6 @@ describe('<md-select>', function() {
153
158
expect ( $rootScope . myForm . select . $touched ) . toBe ( true ) ;
154
159
} ) ) ;
155
160
156
-
157
161
it ( 'restores focus to select when the menu is closed' , inject ( function ( $document ) {
158
162
var select = setupSelect ( 'ng-model="val"' ) . find ( 'md-select' ) ;
159
163
openSelect ( select ) ;
@@ -186,6 +190,11 @@ describe('<md-select>', function() {
186
190
187
191
} ) ) ;
188
192
193
+ it ( 'should remove the tabindex from a disabled element' , inject ( function ( $document ) {
194
+ var select = setupSelect ( 'ng-model="val" disabled tabindex="1"' ) . find ( 'md-select' ) ;
195
+ expect ( select . attr ( 'tabindex' ) ) . toBeUndefined ( ) ;
196
+ } ) ) ;
197
+
189
198
describe ( 'input container' , function ( ) {
190
199
it ( 'should set has-value class on container for non-ng-model input' , inject ( function ( $rootScope ) {
191
200
var el = setupSelect ( 'ng-model="$root.model"' , [ 1 , 2 , 3 ] ) ;
@@ -210,7 +219,7 @@ describe('<md-select>', function() {
210
219
} ) ) ;
211
220
212
221
it ( 'should match label to given input id' , function ( ) {
213
- var el = setupSelect ( 'ng-model="$root.value", id="foo"' ) ;
222
+ var el = setupSelect ( 'ng-model="$root.value" id="foo"' ) ;
214
223
expect ( el . find ( 'label' ) . attr ( 'for' ) ) . toBe ( 'foo' ) ;
215
224
expect ( el . find ( 'md-select' ) . attr ( 'id' ) ) . toBe ( 'foo' ) ;
216
225
} ) ;
@@ -224,7 +233,7 @@ describe('<md-select>', function() {
224
233
225
234
describe ( 'label behavior' , function ( ) {
226
235
it ( 'defaults to the placeholder text' , function ( ) {
227
- var select = setupSelect ( 'ng-model="someVal", placeholder="Hello world"' , null , true ) . find ( 'md-select' ) ;
236
+ var select = setupSelect ( 'ng-model="someVal" placeholder="Hello world"' , null , true ) . find ( 'md-select' ) ;
228
237
var label = select . find ( 'md-select-value' ) ;
229
238
expect ( label . text ( ) ) . toBe ( 'Hello world' ) ;
230
239
expect ( label . hasClass ( '_md-select-placeholder' ) ) . toBe ( true ) ;
@@ -486,7 +495,7 @@ describe('<md-select>', function() {
486
495
changesCalled = true ;
487
496
} ;
488
497
489
- var selectEl = setupSelect ( 'ng-model="myModel", ng-change="changed()"' , [ 1 , 2 , 3 ] ) . find ( 'md-select' ) ;
498
+ var selectEl = setupSelect ( 'ng-model="myModel" ng-change="changed()"' , [ 1 , 2 , 3 ] ) . find ( 'md-select' ) ;
490
499
openSelect ( selectEl ) ;
491
500
492
501
var menuEl = $document . find ( 'md-select-menu' ) ;
@@ -815,7 +824,7 @@ describe('<md-select>', function() {
815
824
} ) ) ;
816
825
817
826
it ( 'adds an aria-label from placeholder' , function ( ) {
818
- var select = setupSelect ( 'ng-model="someVal", placeholder="Hello world"' , null , true ) . find ( 'md-select' ) ;
827
+ var select = setupSelect ( 'ng-model="someVal" placeholder="Hello world"' , null , true ) . find ( 'md-select' ) ;
819
828
expect ( select . attr ( 'aria-label' ) ) . toBe ( 'Hello world' ) ;
820
829
} ) ;
821
830
@@ -835,7 +844,7 @@ describe('<md-select>', function() {
835
844
} ) ) ;
836
845
837
846
it ( 'preserves existing aria-label' , function ( ) {
838
- var select = setupSelect ( 'ng-model="someVal", aria-label="Hello world", placeholder="Pick"' ) . find ( 'md-select' ) ;
847
+ var select = setupSelect ( 'ng-model="someVal" aria-label="Hello world" placeholder="Pick"' ) . find ( 'md-select' ) ;
839
848
expect ( select . attr ( 'aria-label' ) ) . toBe ( 'Hello world' ) ;
840
849
} ) ;
841
850
0 commit comments