Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 90eb3a9

Browse files
author
Marcy Sutton
committed
feat(ngAria): Adds button role to ng-click
Closes #9254
1 parent 84a9dc9 commit 90eb3a9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/ngAria/aria.js

+4
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
329329
}
330330
});
331331
}
332+
333+
if (!elem.attr('role') && (elem[0].nodeName !== 'BUTTON') && (elem[0].nodeName !== 'A')) {
334+
elem.attr('role', 'button');
335+
}
332336
}
333337
};
334338
}])

test/ngAria/ariaSpec.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('$aria', function() {
55

66
beforeEach(module('ngAria'));
77

8-
afterEach(function(){
8+
afterEach(function() {
99
dealoc(element);
1010
});
1111

@@ -143,6 +143,15 @@ describe('$aria', function() {
143143
describe('roles for custom inputs', function() {
144144
beforeEach(injectScopeAndCompiler);
145145

146+
it('should add missing role="button" to custom input', function() {
147+
compileInput('<div ng-click="someFunction()"></div>');
148+
expect(element.attr('role')).toBe('button');
149+
});
150+
it('should not add role="button" to anchor', function() {
151+
compileInput('<a ng-click="someFunction()"></a>');
152+
expect(element.attr('role')).not.toBe('button');
153+
});
154+
146155
it('should add missing role="checkbox" to custom input', function() {
147156
scope.$apply('val = true');
148157
compileInput('<div type="checkbox" ng-model="val"></div>');

0 commit comments

Comments
 (0)