|
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}.
|
@@ -317,17 +317,22 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
317 | 317 | var fn = $parse(attr.ngClick, /* interceptorFn */ null, /* expensiveChecks */ true);
|
318 | 318 | return function(scope, elem, attr) {
|
319 | 319 |
|
| 320 | + var nodeBlackList = ['BUTTON', 'A', 'INPUT', 'TEXTAREA']; |
| 321 | + |
320 | 322 | function isNodeOneOf(elem, nodeTypeArray) {
|
321 | 323 | if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
|
322 | 324 | return true;
|
323 | 325 | }
|
324 | 326 | }
|
| 327 | + if (!elem.attr('role') && !isNodeOneOf(elem, nodeBlackList)) { |
| 328 | + elem.attr('role', 'button'); |
| 329 | + } |
325 | 330 |
|
326 | 331 | if ($aria.config('tabindex') && !elem.attr('tabindex')) {
|
327 | 332 | elem.attr('tabindex', 0);
|
328 | 333 | }
|
329 | 334 |
|
330 |
| - if ($aria.config('bindKeypress') && !attr.ngKeypress && isNodeOneOf(elem, ['DIV', 'LI'])) { |
| 335 | + if ($aria.config('bindKeypress') && !attr.ngKeypress && !isNodeOneOf(elem, nodeBlackList)) { |
331 | 336 | elem.on('keypress', function(event) {
|
332 | 337 | if (event.keyCode === 32 || event.keyCode === 13) {
|
333 | 338 | scope.$apply(callback);
|
|
0 commit comments