|
20 | 20 | *
|
21 | 21 | * Below is a more detailed breakdown of the attributes handled by ngAria:
|
22 | 22 | *
|
23 |
| - * | Directive | Supported Attributes | |
24 |
| - * |---------------------------------------------|----------------------------------------------------------------------------------------| |
25 |
| - * | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required | |
26 |
| - * | {@link ng.directive:ngDisabled ngDisabled} | aria-disabled | |
27 |
| - * | {@link ng.directive:ngShow ngShow} | aria-hidden | |
28 |
| - * | {@link ng.directive:ngHide ngHide} | aria-hidden | |
29 |
| - * | {@link ng.directive:ngClick ngClick} | tabindex, keypress event | |
30 |
| - * | {@link ng.directive:ngDblclick ngDblclick} | tabindex | |
31 |
| - * | {@link module:ngMessages ngMessages} | aria-live | |
| 23 | + * | Directive | Supported Attributes | |
| 24 | + * |---------------------------------------------|-----------------------------------------------------------------------------------------------------| |
| 25 | + * | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required, input roles | |
| 26 | + * | {@link ng.directive:ngDisabled ngDisabled} | aria-disabled | |
| 27 | + * | {@link ng.directive:ngShow ngShow} | aria-hidden | |
| 28 | + * | {@link ng.directive:ngHide ngHide} | aria-hidden | |
| 29 | + * | {@link ng.directive:ngClick ngClick} | tabindex, keypress event, button role | |
| 30 | + * | {@link ng.directive:ngDblclick ngDblclick} | tabindex | |
| 31 | + * | {@link module:ngMessages ngMessages} | aria-live | |
32 | 32 | *
|
33 | 33 | * Find out more information about each directive by reading the
|
34 | 34 | * {@link guide/accessibility ngAria Developer Guide}.
|
@@ -329,6 +329,18 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
329 | 329 | }
|
330 | 330 | });
|
331 | 331 | }
|
| 332 | + |
| 333 | + function isNodeOneOf(elem, nodeTypeArray) { |
| 334 | + for (var i=0; i < nodeTypeArray.length; i++) { |
| 335 | + if (elem[0].nodeName === nodeTypeArray[i]) { |
| 336 | + return true; |
| 337 | + } |
| 338 | + } |
| 339 | + } |
| 340 | + |
| 341 | + if (!elem.attr('role') && !isNodeOneOf(elem, ['BUTTON', 'A'])) { |
| 342 | + elem.attr('role', 'button'); |
| 343 | + } |
332 | 344 | }
|
333 | 345 | };
|
334 | 346 | }])
|
|
0 commit comments