22
22
*
23
23
* | Directive | Supported Attributes |
24
24
* |---------------------------------------------|----------------------------------------------------------------------------------------|
25
- * | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required |
26
25
* | {@link ng.directive:ngDisabled ngDisabled} | aria-disabled |
27
26
* | {@link ng.directive:ngShow ngShow} | aria-hidden |
28
27
* | {@link ng.directive:ngHide ngHide} | aria-hidden |
29
- * | {@link ng.directive:ngClick ngClick} | tabindex, keypress event |
30
28
* | {@link ng.directive:ngDblclick ngDblclick} | tabindex |
31
29
* | {@link module:ngMessages ngMessages} | aria-live |
30
+ * | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required, input roles |
31
+ * | {@link ng.directive:ngClick ngClick} | tabindex, keypress event, button role |
32
32
*
33
33
* Find out more information about each directive by reading the
34
34
* {@link guide/accessibility ngAria Developer Guide}.
@@ -320,6 +320,9 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
320
320
return true ;
321
321
}
322
322
}
323
+ if ( ! elem . attr ( 'role' ) && ! isNodeOneOf ( elem , [ 'BUTTON' , 'A' ] ) ) {
324
+ elem . attr ( 'role' , 'button' ) ;
325
+ }
323
326
324
327
if ( $aria . config ( 'tabindex' ) && ! elem . attr ( 'tabindex' ) ) {
325
328
elem . attr ( 'tabindex' , 0 ) ;
@@ -337,6 +340,16 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
337
340
} ) ;
338
341
}
339
342
} ;
343
+
344
+ function isNodeOneOf ( elem , nodeTypeArray ) {
345
+ for ( var i = 0 ; i < nodeTypeArray . length ; i ++ ) {
346
+ if ( elem [ 0 ] . nodeName === nodeTypeArray [ i ] ) {
347
+ return true ;
348
+ }
349
+ }
350
+ }
351
+
352
+
340
353
}
341
354
} ;
342
355
} ] )
0 commit comments