diff --git a/src/ngAria/aria.js b/src/ngAria/aria.js index b1aa260828a2..c1038f2f26c7 100644 --- a/src/ngAria/aria.js +++ b/src/ngAria/aria.js @@ -83,7 +83,8 @@ function $AriaProvider() { ariaMultiline: true, ariaValue: true, tabindex: true, - bindKeypress: true + bindKeypress: true, + bindRoleForClick: true }; /** @@ -102,6 +103,8 @@ function $AriaProvider() { * - **tabindex** – `{boolean}` – Enables/disables tabindex tags * - **bindKeypress** – `{boolean}` – Enables/disables keypress event binding on `<div>` and * `<li>` elements with ng-click + * - **bindRoleForClick** – `{boolean}` – Adds role=button to non-interactive elements like `div` + * using ng-click, making them more accessible to users of assistive technologies * * @description * Enables/disables various ARIA attributes @@ -346,7 +349,10 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) { return true; } } - if (!elem.attr('role') && !isNodeOneOf(elem, nodeBlackList)) { + + if ($aria.config('bindRoleForClick') + && !elem.attr('role') + && !isNodeOneOf(elem, nodeBlackList)) { elem.attr('role', 'button'); } diff --git a/test/ngAria/ariaSpec.js b/test/ngAria/ariaSpec.js index 728598f8e74c..864f856ed271 100644 --- a/test/ngAria/ariaSpec.js +++ b/test/ngAria/ariaSpec.js @@ -750,6 +750,18 @@ describe('$aria', function() { }); }); + describe('actions when bindRoleForClick is set to false', function() { + beforeEach(configAriaProvider({ + bindRoleForClick: false + })); + beforeEach(injectScopeAndCompiler); + + it('should not add a button role', function() { + compileElement(''); + expect(element.attr('role')).toBeUndefined(); + }); + }); + describe('actions when bindKeypress is set to false', function() { beforeEach(configAriaProvider({ bindKeypress: false