@@ -29,6 +29,17 @@ describe('$aria', function(){
29
29
expectAriaAttr ( element , 'aria-hidden' , 'true' ) ;
30
30
} ) ) ;
31
31
32
+ it ( 'should not attach if an aria-hidden is already present' , inject ( function ( $compile , $rootScope ) {
33
+ var element = [
34
+ $compile ( '<div ng-show="val" aria-hidden="userSetValue"></div>' ) ( $rootScope ) ,
35
+ $compile ( '<div ng-hide="val" aria-hidden="userSetValue"></div>' ) ( $rootScope )
36
+ ] ;
37
+ $rootScope . val = true ;
38
+ $rootScope . $digest ( ) ;
39
+
40
+ expectAriaAttr ( element , 'aria-hidden' , 'userSetValue' ) ;
41
+ } ) ) ;
42
+
32
43
describe ( 'disabled' , function ( ) {
33
44
beforeEach ( function ( ) {
34
45
angular . module ( 'ariaTest' , [ 'ngAria' ] ) . config ( function ( $ariaProvider ) {
@@ -92,6 +103,23 @@ describe('$aria', function(){
92
103
expectAriaAttr ( element , 'aria-checked' , 'true' ) ;
93
104
} ) ) ;
94
105
106
+ it ( 'should not attach itself if an aria-checked value is already present' , inject ( function ( $compile , $rootScope ) {
107
+ var element = [
108
+ $compile ( "<input type='checkbox' ng-model='val1' aria-checked='userSetValue'>" ) ( $rootScope ) ,
109
+ $compile ( "<input type='radio' ng-model='val2' value='one' aria-checked='userSetValue'><input type='radio' ng-model='val2' value='two'>" ) ( $rootScope ) ,
110
+ $compile ( "<div role='radio' ng-model='val' value='{{val3}}' aria-checked='userSetValue'></div>" ) ( $rootScope ) ,
111
+ $compile ( "<div role='menuitemradio' ng-model='val' value='{{val3}}' aria-checked='userSetValue'></div>" ) ( $rootScope ) ,
112
+ $compile ( "<div role='checkbox' checked='checked' aria-checked='userSetValue'></div>" ) ( $rootScope ) ,
113
+ $compile ( "<div role='menuitemcheckbox' checked='checked' aria-checked='userSetValue'></div>" ) ( $rootScope )
114
+ ] ;
115
+ $rootScope . val1 = true ;
116
+ $rootScope . val2 = 'one' ;
117
+ $rootScope . val3 = '1' ;
118
+ $rootScope . $digest ( ) ;
119
+
120
+ expectAriaAttr ( element , 'aria-checked' , 'userSetValue' ) ;
121
+ } ) ) ;
122
+
95
123
describe ( 'disabled' , function ( ) {
96
124
beforeEach ( function ( ) {
97
125
angular . module ( 'ariaTest' , [ 'ngAria' ] ) . config ( function ( $ariaProvider ) {
@@ -136,6 +164,19 @@ describe('$aria', function(){
136
164
expectAriaAttr ( element , 'aria-disabled' , 'true' ) ;
137
165
} ) ) ;
138
166
167
+ it ( 'should not attach itself if an aria tag is already present' , inject ( function ( $compile , $rootScope ) {
168
+ var element = [
169
+ $compile ( "<input aria-disabled='userSetValue' ng-disabled='val'>" ) ( $rootScope ) ,
170
+ $compile ( "<textarea aria-disabled='userSetValue' ng-disabled='val'></textarea>" ) ( $rootScope ) ,
171
+ $compile ( "<button aria-disabled='userSetValue' ng-disabled='val'></button>" ) ( $rootScope ) ,
172
+ $compile ( "<select aria-disabled='userSetValue' ng-disabled='val'></select>" ) ( $rootScope )
173
+ ] ;
174
+
175
+ $rootScope . val = true ;
176
+ $rootScope . $digest ( ) ;
177
+ expectAriaAttr ( element , 'aria-disabled' , 'userSetValue' ) ;
178
+ } ) ) ;
179
+
139
180
describe ( 'disabled' , function ( ) {
140
181
beforeEach ( function ( ) {
141
182
angular . module ( 'ariaTest' , [ 'ngAria' ] ) . config ( function ( $ariaProvider ) {
@@ -176,6 +217,13 @@ describe('$aria', function(){
176
217
expectAriaAttr ( element , 'aria-invalid' , 'false' ) ;
177
218
} ) ) ;
178
219
220
+ it ( 'should not attach itself if aria-invalid is already present' , inject ( function ( $compile , $rootScope ) {
221
+ var element = $compile ( "<input ng-model='txtInput' ng-minlength='10' aria-invalid='userSetValue'>" ) ( $rootScope ) ;
222
+ $rootScope . txtInput = "LTten" ;
223
+ $rootScope . $digest ( ) ;
224
+ expectAriaAttr ( element , 'aria-invalid' , 'userSetValue' ) ;
225
+ } ) ) ;
226
+
179
227
describe ( 'disabled' , function ( ) {
180
228
beforeEach ( function ( ) {
181
229
angular . module ( 'ariaTest' , [ 'ngAria' ] ) . config ( function ( $ariaProvider ) {
@@ -222,6 +270,18 @@ describe('$aria', function(){
222
270
expectAriaAttr ( element , 'aria-required' , 'false' ) ;
223
271
} ) ) ;
224
272
273
+ it ( 'should not attach itself if aria-required is already present' , inject ( function ( $compile , $rootScope ) {
274
+ var element = [
275
+ $compile ( "<input ng-model='val' required aria-required='userSetValue'>" ) ( $rootScope ) ,
276
+ $compile ( "<textarea ng-model='val' required aria-required='userSetValue'></textarea>" ) ( $rootScope ) ,
277
+ $compile ( "<select ng-model='val' required aria-required='userSetValue'></select>" ) ( $rootScope ) ,
278
+ $compile ( "<input ng-model='val' ng-required='true' aria-required='userSetValue'>" ) ( $rootScope )
279
+ ] ;
280
+
281
+ $rootScope . $digest ( ) ;
282
+ expectAriaAttr ( element , 'aria-required' , 'userSetValue' ) ;
283
+ } ) ) ;
284
+
225
285
describe ( 'disabled' , function ( ) {
226
286
beforeEach ( function ( ) {
227
287
angular . module ( 'ariaTest' , [ 'ngAria' ] ) . config ( function ( $ariaProvider ) {
@@ -259,6 +319,16 @@ describe('$aria', function(){
259
319
expectAriaAttr ( element , 'aria-multiline' , 'true' ) ;
260
320
} ) ) ;
261
321
322
+ it ( 'should not attach if aria-multiline is already present' , inject ( function ( $compile , $rootScope ) {
323
+ var element = [
324
+ $compile ( "<textarea aria-multiline='userSetValue'></textarea>" ) ( $rootScope ) ,
325
+ $compile ( "<div role='textbox' aria-multiline='userSetValue'></div>" ) ( $rootScope )
326
+ ] ;
327
+
328
+ $rootScope . $digest ( ) ;
329
+ expectAriaAttr ( element , 'aria-multiline' , 'userSetValue' ) ;
330
+ } ) ) ;
331
+
262
332
describe ( 'disabled' , function ( ) {
263
333
beforeEach ( function ( ) {
264
334
angular . module ( 'ariaTest' , [ 'ngAria' ] ) . config ( function ( $ariaProvider ) {
@@ -303,6 +373,20 @@ describe('$aria', function(){
303
373
expectAriaAttr ( element , 'aria-valuenow' , "90" ) ;
304
374
} ) ) ;
305
375
376
+ it ( 'should not attach if aria-value* is already present' , inject ( function ( $compile , $rootScope ) {
377
+ var element = [
378
+ $compile ( '<input type="range" ng-model="val" min="0" max="100" aria-valuenow="userSetValue1" aria-valuemin="userSetValue2" aria-valuemax="userSetValue3">' ) ( $rootScope ) ,
379
+ $compile ( '<div role="progressbar" min="0" max="100" ng-model="val" aria-valuenow="userSetValue1" aria-valuemin="userSetValue2" aria-valuemax="userSetValue3">' ) ( $rootScope ) ,
380
+ $compile ( '<div role="slider" min="0" max="100" ng-model="val" aria-valuenow="userSetValue1" aria-valuemin="userSetValue2" aria-valuemax="userSetValue3">' ) ( $rootScope )
381
+ ] ;
382
+ $rootScope . val = 50 ;
383
+ $rootScope . $digest ( ) ;
384
+
385
+ expectAriaAttr ( element , 'aria-valuenow' , "userSetValue1" ) ;
386
+ expectAriaAttr ( element , 'aria-valuemin' , "userSetValue2" ) ;
387
+ expectAriaAttr ( element , 'aria-valuemax' , "userSetValue3" ) ;
388
+ } ) ) ;
389
+
306
390
describe ( 'disabled' , function ( ) {
307
391
beforeEach ( function ( ) {
308
392
angular . module ( 'ariaTest' , [ 'ngAria' ] ) . config ( function ( $ariaProvider ) {
0 commit comments