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