@@ -5,7 +5,7 @@ describe('$aria', function() {
5
5
6
6
beforeEach ( module ( 'ngAria' ) ) ;
7
7
8
- afterEach ( function ( ) {
8
+ afterEach ( function ( ) {
9
9
dealoc ( element ) ;
10
10
} ) ;
11
11
@@ -16,7 +16,7 @@ describe('$aria', function() {
16
16
} ) ;
17
17
}
18
18
19
- function compileInput ( inputHtml ) {
19
+ function compileElement ( inputHtml ) {
20
20
element = $compile ( inputHtml ) ( scope ) ;
21
21
scope . $digest ( ) ;
22
22
}
@@ -25,7 +25,7 @@ describe('$aria', function() {
25
25
beforeEach ( injectScopeAndCompiler ) ;
26
26
27
27
it ( 'should attach aria-hidden to ng-show' , function ( ) {
28
- compileInput ( '<div ng-show="val"></div>' ) ;
28
+ compileElement ( '<div ng-show="val"></div>' ) ;
29
29
scope . $apply ( 'val = false' ) ;
30
30
expect ( element . attr ( 'aria-hidden' ) ) . toBe ( 'true' ) ;
31
31
@@ -34,7 +34,7 @@ describe('$aria', function() {
34
34
} ) ;
35
35
36
36
it ( 'should attach aria-hidden to ng-hide' , function ( ) {
37
- compileInput ( '<div ng-hide="val"></div>' ) ;
37
+ compileElement ( '<div ng-hide="val"></div>' ) ;
38
38
scope . $apply ( 'val = false' ) ;
39
39
expect ( element . attr ( 'aria-hidden' ) ) . toBe ( 'false' ) ;
40
40
@@ -43,15 +43,15 @@ describe('$aria', function() {
43
43
} ) ;
44
44
45
45
it ( 'should not change aria-hidden if it is already present on ng-show' , function ( ) {
46
- compileInput ( '<div ng-show="val" aria-hidden="userSetValue"></div>' ) ;
46
+ compileElement ( '<div ng-show="val" aria-hidden="userSetValue"></div>' ) ;
47
47
expect ( element . attr ( 'aria-hidden' ) ) . toBe ( 'userSetValue' ) ;
48
48
49
49
scope . $apply ( 'val = true' ) ;
50
50
expect ( element . attr ( 'aria-hidden' ) ) . toBe ( 'userSetValue' ) ;
51
51
} ) ;
52
52
53
53
it ( 'should not change aria-hidden if it is already present on ng-hide' , function ( ) {
54
- compileInput ( '<div ng-hide="val" aria-hidden="userSetValue"></div>' ) ;
54
+ compileElement ( '<div ng-hide="val" aria-hidden="userSetValue"></div>' ) ;
55
55
expect ( element . attr ( 'aria-hidden' ) ) . toBe ( 'userSetValue' ) ;
56
56
57
57
scope . $apply ( 'val = true' ) ;
@@ -68,10 +68,10 @@ describe('$aria', function() {
68
68
69
69
it ( 'should not attach aria-hidden' , function ( ) {
70
70
scope . $apply ( 'val = false' ) ;
71
- compileInput ( '<div ng-show="val"></div>' ) ;
71
+ compileElement ( '<div ng-show="val"></div>' ) ;
72
72
expect ( element . attr ( 'aria-hidden' ) ) . toBeUndefined ( ) ;
73
73
74
- compileInput ( '<div ng-hide="val"></div>' ) ;
74
+ compileElement ( '<div ng-hide="val"></div>' ) ;
75
75
expect ( element . attr ( 'aria-hidden' ) ) . toBeUndefined ( ) ;
76
76
} ) ;
77
77
} ) ;
@@ -80,7 +80,7 @@ describe('$aria', function() {
80
80
beforeEach ( injectScopeAndCompiler ) ;
81
81
82
82
it ( 'should attach itself to input type="checkbox"' , function ( ) {
83
- compileInput ( '<input type="checkbox" ng-model="val">' ) ;
83
+ compileElement ( '<input type="checkbox" ng-model="val">' ) ;
84
84
85
85
scope . $apply ( 'val = true' ) ;
86
86
expect ( element . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
@@ -104,25 +104,25 @@ describe('$aria', function() {
104
104
105
105
it ( 'should attach itself to role="radio"' , function ( ) {
106
106
scope . $apply ( "val = 'one'" ) ;
107
- compileInput ( '<div role="radio" ng-model="val" value="{{val}}"></div>' ) ;
107
+ compileElement ( '<div role="radio" ng-model="val" value="{{val}}"></div>' ) ;
108
108
expect ( element . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
109
109
} ) ;
110
110
111
111
it ( 'should attach itself to role="checkbox"' , function ( ) {
112
112
scope . val = true ;
113
- compileInput ( '<div role="checkbox" ng-model="val"></div>' ) ;
113
+ compileElement ( '<div role="checkbox" ng-model="val"></div>' ) ;
114
114
expect ( element . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
115
115
} ) ;
116
116
117
117
it ( 'should attach itself to role="menuitemradio"' , function ( ) {
118
118
scope . val = 'one' ;
119
- compileInput ( '<div role="menuitemradio" ng-model="val" value="{{val}}"></div>' ) ;
119
+ compileElement ( '<div role="menuitemradio" ng-model="val" value="{{val}}"></div>' ) ;
120
120
expect ( element . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
121
121
} ) ;
122
122
123
123
it ( 'should attach itself to role="menuitemcheckbox"' , function ( ) {
124
124
scope . val = true ;
125
- compileInput ( '<div role="menuitemcheckbox" ng-model="val"></div>' ) ;
125
+ compileElement ( '<div role="menuitemcheckbox" ng-model="val"></div>' ) ;
126
126
expect ( element . attr ( 'aria-checked' ) ) . toBe ( 'true' ) ;
127
127
} ) ;
128
128
@@ -143,34 +143,49 @@ describe('$aria', function() {
143
143
describe ( 'roles for custom inputs' , function ( ) {
144
144
beforeEach ( injectScopeAndCompiler ) ;
145
145
146
+ it ( 'should add missing role="button" to custom input' , function ( ) {
147
+ compileElement ( '<div ng-click="someFunction()"></div>' ) ;
148
+ expect ( element . attr ( 'role' ) ) . toBe ( 'button' ) ;
149
+ } ) ;
150
+
151
+ it ( 'should not add role="button" to anchor' , function ( ) {
152
+ compileElement ( '<a ng-click="someFunction()"></a>' ) ;
153
+ expect ( element . attr ( 'role' ) ) . not . toBe ( 'button' ) ;
154
+ } ) ;
155
+
146
156
it ( 'should add missing role="checkbox" to custom input' , function ( ) {
147
157
scope . $apply ( 'val = true' ) ;
148
- compileInput ( '<div type="checkbox" ng-model="val"></div>' ) ;
158
+ compileElement ( '<div type="checkbox" ng-model="val"></div>' ) ;
149
159
expect ( element . attr ( 'role' ) ) . toBe ( 'checkbox' ) ;
150
160
} ) ;
161
+
151
162
it ( 'should not add a role to a native checkbox' , function ( ) {
152
163
scope . $apply ( 'val = true' ) ;
153
- compileInput ( '<input type="checkbox" ng-model="val"></div>' ) ;
164
+ compileElement ( '<input type="checkbox" ng-model="val"></div>' ) ;
154
165
expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
155
166
} ) ;
167
+
156
168
it ( 'should add missing role="radio" to custom input' , function ( ) {
157
169
scope . $apply ( 'val = true' ) ;
158
- compileInput ( '<div type="radio" ng-model="val"></div>' ) ;
170
+ compileElement ( '<div type="radio" ng-model="val"></div>' ) ;
159
171
expect ( element . attr ( 'role' ) ) . toBe ( 'radio' ) ;
160
172
} ) ;
173
+
161
174
it ( 'should not add a role to a native radio button' , function ( ) {
162
175
scope . $apply ( 'val = true' ) ;
163
- compileInput ( '<input type="radio" ng-model="val"></div>' ) ;
176
+ compileElement ( '<input type="radio" ng-model="val"></div>' ) ;
164
177
expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
165
178
} ) ;
179
+
166
180
it ( 'should add missing role="slider" to custom input' , function ( ) {
167
181
scope . $apply ( 'val = true' ) ;
168
- compileInput ( '<div type="range" ng-model="val"></div>' ) ;
182
+ compileElement ( '<div type="range" ng-model="val"></div>' ) ;
169
183
expect ( element . attr ( 'role' ) ) . toBe ( 'slider' ) ;
170
184
} ) ;
185
+
171
186
it ( 'should not add a role to a native range input' , function ( ) {
172
187
scope . $apply ( 'val = true' ) ;
173
- compileInput ( '<input type="range" ng-model="val"></div>' ) ;
188
+ compileElement ( '<input type="range" ng-model="val"></div>' ) ;
174
189
expect ( element . attr ( 'role' ) ) . toBe ( undefined ) ;
175
190
} ) ;
176
191
} ) ;
@@ -182,16 +197,16 @@ describe('$aria', function() {
182
197
beforeEach ( injectScopeAndCompiler ) ;
183
198
184
199
it ( 'should not attach aria-checked' , function ( ) {
185
- compileInput ( "<div role='radio' ng-model='val' value='{{val}}'></div>" ) ;
200
+ compileElement ( "<div role='radio' ng-model='val' value='{{val}}'></div>" ) ;
186
201
expect ( element . attr ( 'aria-checked' ) ) . toBeUndefined ( ) ;
187
202
188
- compileInput ( "<div role='menuitemradio' ng-model='val' value='{{val}}'></div>" ) ;
203
+ compileElement ( "<div role='menuitemradio' ng-model='val' value='{{val}}'></div>" ) ;
189
204
expect ( element . attr ( 'aria-checked' ) ) . toBeUndefined ( ) ;
190
205
191
- compileInput ( "<div role='checkbox' checked='checked'></div>" ) ;
206
+ compileElement ( "<div role='checkbox' checked='checked'></div>" ) ;
192
207
expect ( element . attr ( 'aria-checked' ) ) . toBeUndefined ( ) ;
193
208
194
- compileInput ( "<div role='menuitemcheckbox' checked='checked'></div>" ) ;
209
+ compileElement ( "<div role='menuitemcheckbox' checked='checked'></div>" ) ;
195
210
expect ( element . attr ( 'aria-checked' ) ) . toBeUndefined ( ) ;
196
211
} ) ;
197
212
} ) ;
@@ -201,7 +216,7 @@ describe('$aria', function() {
201
216
202
217
it ( 'should attach itself to input elements' , function ( ) {
203
218
scope . $apply ( 'val = false' ) ;
204
- compileInput ( "<input ng-disabled='val'>" ) ;
219
+ compileElement ( "<input ng-disabled='val'>" ) ;
205
220
expect ( element . attr ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
206
221
207
222
scope . $apply ( 'val = true' ) ;
@@ -210,7 +225,7 @@ describe('$aria', function() {
210
225
211
226
it ( 'should attach itself to textarea elements' , function ( ) {
212
227
scope . $apply ( 'val = false' ) ;
213
- compileInput ( '<textarea ng-disabled="val"></textarea>' ) ;
228
+ compileElement ( '<textarea ng-disabled="val"></textarea>' ) ;
214
229
expect ( element . attr ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
215
230
216
231
scope . $apply ( 'val = true' ) ;
@@ -219,7 +234,7 @@ describe('$aria', function() {
219
234
220
235
it ( 'should attach itself to button elements' , function ( ) {
221
236
scope . $apply ( 'val = false' ) ;
222
- compileInput ( '<button ng-disabled="val"></button>' ) ;
237
+ compileElement ( '<button ng-disabled="val"></button>' ) ;
223
238
expect ( element . attr ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
224
239
225
240
scope . $apply ( 'val = true' ) ;
@@ -228,7 +243,7 @@ describe('$aria', function() {
228
243
229
244
it ( 'should attach itself to select elements' , function ( ) {
230
245
scope . $apply ( 'val = false' ) ;
231
- compileInput ( '<select ng-disabled="val"></select>' ) ;
246
+ compileElement ( '<select ng-disabled="val"></select>' ) ;
232
247
expect ( element . attr ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
233
248
234
249
scope . $apply ( 'val = true' ) ;
@@ -271,7 +286,7 @@ describe('$aria', function() {
271
286
beforeEach ( injectScopeAndCompiler ) ;
272
287
273
288
it ( 'should attach aria-invalid to input' , function ( ) {
274
- compileInput ( '<input ng-model="txtInput" ng-minlength="10">' ) ;
289
+ compileElement ( '<input ng-model="txtInput" ng-minlength="10">' ) ;
275
290
scope . $apply ( "txtInput='LTten'" ) ;
276
291
expect ( element . attr ( 'aria-invalid' ) ) . toBe ( 'true' ) ;
277
292
@@ -280,7 +295,7 @@ describe('$aria', function() {
280
295
} ) ;
281
296
282
297
it ( 'should not attach itself if aria-invalid is already present' , function ( ) {
283
- compileInput ( '<input ng-model="txtInput" ng-minlength="10" aria-invalid="userSetValue">' ) ;
298
+ compileElement ( '<input ng-model="txtInput" ng-minlength="10" aria-invalid="userSetValue">' ) ;
284
299
scope . $apply ( "txtInput='LTten'" ) ;
285
300
expect ( element . attr ( 'aria-invalid' ) ) . toBe ( 'userSetValue' ) ;
286
301
} ) ;
@@ -294,7 +309,7 @@ describe('$aria', function() {
294
309
295
310
it ( 'should not attach aria-invalid if the option is disabled' , function ( ) {
296
311
scope . $apply ( "txtInput='LTten'" ) ;
297
- compileInput ( '<input ng-model="txtInput" ng-minlength="10">' ) ;
312
+ compileElement ( '<input ng-model="txtInput" ng-minlength="10">' ) ;
298
313
expect ( element . attr ( 'aria-invalid' ) ) . toBeUndefined ( ) ;
299
314
} ) ;
300
315
} ) ;
@@ -303,48 +318,48 @@ describe('$aria', function() {
303
318
beforeEach ( injectScopeAndCompiler ) ;
304
319
305
320
it ( 'should attach aria-required to input' , function ( ) {
306
- compileInput ( '<input ng-model="val" required>' ) ;
321
+ compileElement ( '<input ng-model="val" required>' ) ;
307
322
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'true' ) ;
308
323
309
324
scope . $apply ( "val='input is valid now'" ) ;
310
325
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'false' ) ;
311
326
} ) ;
312
327
313
328
it ( 'should attach aria-required to textarea' , function ( ) {
314
- compileInput ( '<textarea ng-model="val" required></textarea>' ) ;
329
+ compileElement ( '<textarea ng-model="val" required></textarea>' ) ;
315
330
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'true' ) ;
316
331
317
332
scope . $apply ( "val='input is valid now'" ) ;
318
333
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'false' ) ;
319
334
} ) ;
320
335
321
336
it ( 'should attach aria-required to select' , function ( ) {
322
- compileInput ( '<select ng-model="val" required></select>' ) ;
337
+ compileElement ( '<select ng-model="val" required></select>' ) ;
323
338
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'true' ) ;
324
339
325
340
scope . $apply ( "val='input is valid now'" ) ;
326
341
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'false' ) ;
327
342
} ) ;
328
343
329
344
it ( 'should attach aria-required to ngRequired' , function ( ) {
330
- compileInput ( '<input ng-model="val" ng-required="true">' ) ;
345
+ compileElement ( '<input ng-model="val" ng-required="true">' ) ;
331
346
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'true' ) ;
332
347
333
348
scope . $apply ( "val='input is valid now'" ) ;
334
349
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'false' ) ;
335
350
} ) ;
336
351
337
352
it ( 'should not attach itself if aria-required is already present' , function ( ) {
338
- compileInput ( "<input ng-model='val' required aria-required='userSetValue'>" ) ;
353
+ compileElement ( "<input ng-model='val' required aria-required='userSetValue'>" ) ;
339
354
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'userSetValue' ) ;
340
355
341
- compileInput ( "<textarea ng-model='val' required aria-required='userSetValue'></textarea>" ) ;
356
+ compileElement ( "<textarea ng-model='val' required aria-required='userSetValue'></textarea>" ) ;
342
357
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'userSetValue' ) ;
343
358
344
- compileInput ( "<select ng-model='val' required aria-required='userSetValue'></select>" ) ;
359
+ compileElement ( "<select ng-model='val' required aria-required='userSetValue'></select>" ) ;
345
360
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'userSetValue' ) ;
346
361
347
- compileInput ( "<input ng-model='val' ng-required='true' aria-required='userSetValue'>" ) ;
362
+ compileElement ( "<input ng-model='val' ng-required='true' aria-required='userSetValue'>" ) ;
348
363
expect ( element . attr ( 'aria-required' ) ) . toBe ( 'userSetValue' ) ;
349
364
} ) ;
350
365
} ) ;
@@ -356,13 +371,13 @@ describe('$aria', function() {
356
371
beforeEach ( injectScopeAndCompiler ) ;
357
372
358
373
it ( 'should not add the aria-required attribute' , function ( ) {
359
- compileInput ( "<input ng-model='val' required>" ) ;
374
+ compileElement ( "<input ng-model='val' required>" ) ;
360
375
expect ( element . attr ( 'aria-required' ) ) . toBeUndefined ( ) ;
361
376
362
- compileInput ( "<textarea ng-model='val' required></textarea>" ) ;
377
+ compileElement ( "<textarea ng-model='val' required></textarea>" ) ;
363
378
expect ( element . attr ( 'aria-required' ) ) . toBeUndefined ( ) ;
364
379
365
- compileInput ( "<select ng-model='val' required></select>" ) ;
380
+ compileElement ( "<select ng-model='val' required></select>" ) ;
366
381
expect ( element . attr ( 'aria-required' ) ) . toBeUndefined ( ) ;
367
382
} ) ;
368
383
} ) ;
@@ -371,20 +386,20 @@ describe('$aria', function() {
371
386
beforeEach ( injectScopeAndCompiler ) ;
372
387
373
388
it ( 'should attach itself to textarea' , function ( ) {
374
- compileInput ( '<textarea ng-model="val"></textarea>' ) ;
389
+ compileElement ( '<textarea ng-model="val"></textarea>' ) ;
375
390
expect ( element . attr ( 'aria-multiline' ) ) . toBe ( 'true' ) ;
376
391
} ) ;
377
392
378
393
it ( 'should attach itself role="textbox"' , function ( ) {
379
- compileInput ( '<div role="textbox" ng-model="val"></div>' ) ;
394
+ compileElement ( '<div role="textbox" ng-model="val"></div>' ) ;
380
395
expect ( element . attr ( 'aria-multiline' ) ) . toBe ( 'true' ) ;
381
396
} ) ;
382
397
383
398
it ( 'should not attach itself if aria-multiline is already present' , function ( ) {
384
- compileInput ( '<textarea aria-multiline="userSetValue"></textarea>' ) ;
399
+ compileElement ( '<textarea aria-multiline="userSetValue"></textarea>' ) ;
385
400
expect ( element . attr ( 'aria-multiline' ) ) . toBe ( 'userSetValue' ) ;
386
401
387
- compileInput ( '<div role="textbox" aria-multiline="userSetValue"></div>' ) ;
402
+ compileElement ( '<div role="textbox" aria-multiline="userSetValue"></div>' ) ;
388
403
expect ( element . attr ( 'aria-multiline' ) ) . toBe ( 'userSetValue' ) ;
389
404
} ) ;
390
405
} ) ;
@@ -396,12 +411,12 @@ describe('$aria', function() {
396
411
beforeEach ( injectScopeAndCompiler ) ;
397
412
398
413
it ( 'should not attach itself to textarea' , function ( ) {
399
- compileInput ( '<textarea></textarea>' ) ;
414
+ compileElement ( '<textarea></textarea>' ) ;
400
415
expect ( element . attr ( 'aria-multiline' ) ) . toBeUndefined ( ) ;
401
416
} ) ;
402
417
403
418
it ( 'should not attach itself role="textbox"' , function ( ) {
404
- compileInput ( '<div role="textbox"></div>' ) ;
419
+ compileElement ( '<div role="textbox"></div>' ) ;
405
420
expect ( element . attr ( 'aria-multiline' ) ) . toBeUndefined ( ) ;
406
421
} ) ;
407
422
} ) ;
@@ -459,12 +474,12 @@ describe('$aria', function() {
459
474
it ( 'should not attach itself' , function ( ) {
460
475
scope . $apply ( 'val = 50' ) ;
461
476
462
- compileInput ( '<input type="range" ng-model="val" min="0" max="100">' ) ;
477
+ compileElement ( '<input type="range" ng-model="val" min="0" max="100">' ) ;
463
478
expect ( element . attr ( 'aria-valuenow' ) ) . toBeUndefined ( ) ;
464
479
expect ( element . attr ( 'aria-valuemin' ) ) . toBeUndefined ( ) ;
465
480
expect ( element . attr ( 'aria-valuemax' ) ) . toBeUndefined ( ) ;
466
481
467
- compileInput ( '<div role="progressbar" min="0" max="100" ng-model="val">' ) ;
482
+ compileElement ( '<div role="progressbar" min="0" max="100" ng-model="val">' ) ;
468
483
expect ( element . attr ( 'aria-valuenow' ) ) . toBeUndefined ( ) ;
469
484
expect ( element . attr ( 'aria-valuemin' ) ) . toBeUndefined ( ) ;
470
485
expect ( element . attr ( 'aria-valuemax' ) ) . toBeUndefined ( ) ;
@@ -475,32 +490,32 @@ describe('$aria', function() {
475
490
beforeEach ( injectScopeAndCompiler ) ;
476
491
477
492
it ( 'should attach tabindex to role="checkbox", ng-click, and ng-dblclick' , function ( ) {
478
- compileInput ( '<div role="checkbox" ng-model="val"></div>' ) ;
493
+ compileElement ( '<div role="checkbox" ng-model="val"></div>' ) ;
479
494
expect ( element . attr ( 'tabindex' ) ) . toBe ( '0' ) ;
480
495
481
- compileInput ( '<div ng-click="someAction()"></div>' ) ;
496
+ compileElement ( '<div ng-click="someAction()"></div>' ) ;
482
497
expect ( element . attr ( 'tabindex' ) ) . toBe ( '0' ) ;
483
498
484
- compileInput ( '<div ng-dblclick="someAction()"></div>' ) ;
499
+ compileElement ( '<div ng-dblclick="someAction()"></div>' ) ;
485
500
expect ( element . attr ( 'tabindex' ) ) . toBe ( '0' ) ;
486
501
} ) ;
487
502
488
503
it ( 'should not attach tabindex if it is already on an element' , function ( ) {
489
- compileInput ( '<div role="button" tabindex="userSetValue"></div>' ) ;
504
+ compileElement ( '<div role="button" tabindex="userSetValue"></div>' ) ;
490
505
expect ( element . attr ( 'tabindex' ) ) . toBe ( 'userSetValue' ) ;
491
506
492
- compileInput ( '<div role="checkbox" tabindex="userSetValue"></div>' ) ;
507
+ compileElement ( '<div role="checkbox" tabindex="userSetValue"></div>' ) ;
493
508
expect ( element . attr ( 'tabindex' ) ) . toBe ( 'userSetValue' ) ;
494
509
495
- compileInput ( '<div ng-click="someAction()" tabindex="userSetValue"></div>' ) ;
510
+ compileElement ( '<div ng-click="someAction()" tabindex="userSetValue"></div>' ) ;
496
511
expect ( element . attr ( 'tabindex' ) ) . toBe ( 'userSetValue' ) ;
497
512
498
- compileInput ( '<div ng-dblclick="someAction()" tabindex="userSetValue"></div>' ) ;
513
+ compileElement ( '<div ng-dblclick="someAction()" tabindex="userSetValue"></div>' ) ;
499
514
expect ( element . attr ( 'tabindex' ) ) . toBe ( 'userSetValue' ) ;
500
515
} ) ;
501
516
502
517
it ( 'should set proper tabindex values for radiogroup' , function ( ) {
503
- compileInput ( '<div role="radiogroup">' +
518
+ compileElement ( '<div role="radiogroup">' +
504
519
'<div role="radio" ng-model="val" value="one">1</div>' +
505
520
'<div role="radio" ng-model="val" value="two">2</div>' +
506
521
'</div>' ) ;
@@ -553,7 +568,7 @@ describe('$aria', function() {
553
568
554
569
scope . someAction = function ( ) { } ;
555
570
clickFn = spyOn ( scope , 'someAction' ) ;
556
- compileInput ( '<div ng-click="someAction()" ng-keypress="someOtherAction()" tabindex="0"></div>' ) ;
571
+ compileElement ( '<div ng-click="someAction()" ng-keypress="someOtherAction()" tabindex="0"></div>' ) ;
557
572
558
573
element . triggerHandler ( { type : 'keypress' , keyCode : 32 } ) ;
559
574
@@ -562,7 +577,7 @@ describe('$aria', function() {
562
577
} ) ;
563
578
564
579
it ( 'should update bindings when keypress handled' , function ( ) {
565
- compileInput ( '<div ng-click="text = \'clicked!\'">{{text}}</div>' ) ;
580
+ compileElement ( '<div ng-click="text = \'clicked!\'">{{text}}</div>' ) ;
566
581
expect ( element . text ( ) ) . toBe ( '' ) ;
567
582
spyOn ( scope . $root , '$digest' ) . andCallThrough ( ) ;
568
583
element . triggerHandler ( { type : 'keypress' , keyCode : 13 } ) ;
@@ -571,22 +586,22 @@ describe('$aria', function() {
571
586
} ) ;
572
587
573
588
it ( 'should pass $event to ng-click handler as local' , function ( ) {
574
- compileInput ( '<div ng-click="event = $event">{{event.type}}' +
575
- '{{event.keyCode}}</div>' ) ;
589
+ compileElement ( '<div ng-click="event = $event">{{event.type}}' +
590
+ '{{event.keyCode}}</div>' ) ;
576
591
expect ( element . text ( ) ) . toBe ( '' ) ;
577
592
element . triggerHandler ( { type : 'keypress' , keyCode : 13 } ) ;
578
593
expect ( element . text ( ) ) . toBe ( 'keypress13' ) ;
579
594
} ) ;
580
595
581
596
it ( 'should not bind keypress to elements not in the default config' , function ( ) {
582
- compileInput ( '<button ng-click="event = $event">{{event.type}}{{event.keyCode}}</button>' ) ;
597
+ compileElement ( '<button ng-click="event = $event">{{event.type}}{{event.keyCode}}</button>' ) ;
583
598
expect ( element . text ( ) ) . toBe ( '' ) ;
584
599
element . triggerHandler ( { type : 'keypress' , keyCode : 13 } ) ;
585
600
expect ( element . text ( ) ) . toBe ( '' ) ;
586
601
} ) ;
587
602
} ) ;
588
603
589
- describe ( 'actions when bindKeypress set to false' , function ( ) {
604
+ describe ( 'actions when bindKeypress is set to false' , function ( ) {
590
605
beforeEach ( configAriaProvider ( {
591
606
bindKeypress : false
592
607
} ) ) ;
@@ -611,16 +626,16 @@ describe('$aria', function() {
611
626
beforeEach ( injectScopeAndCompiler ) ;
612
627
613
628
it ( 'should not add a tabindex attribute' , function ( ) {
614
- compileInput ( '<div role="button"></div>' ) ;
629
+ compileElement ( '<div role="button"></div>' ) ;
615
630
expect ( element . attr ( 'tabindex' ) ) . toBeUndefined ( ) ;
616
631
617
- compileInput ( '<div role="checkbox"></div>' ) ;
632
+ compileElement ( '<div role="checkbox"></div>' ) ;
618
633
expect ( element . attr ( 'tabindex' ) ) . toBeUndefined ( ) ;
619
634
620
- compileInput ( '<div ng-click="someAction()"></div>' ) ;
635
+ compileElement ( '<div ng-click="someAction()"></div>' ) ;
621
636
expect ( element . attr ( 'tabindex' ) ) . toBeUndefined ( ) ;
622
637
623
- compileInput ( '<div ng-dblclick="someAction()"></div>' ) ;
638
+ compileElement ( '<div ng-dblclick="someAction()"></div>' ) ;
624
639
expect ( element . attr ( 'tabindex' ) ) . toBeUndefined ( ) ;
625
640
} ) ;
626
641
} ) ;
0 commit comments