Skip to content

Commit

Permalink
feat(ngAria): Adds button role to ng-click
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcy Sutton committed Dec 4, 2014
1 parent 84a9dc9 commit b420186
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ngAria/aria.js
Expand Up @@ -329,6 +329,10 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
}
});
}

if (!elem.attr('role') && (elem[0].nodeName !== 'BUTTON') && (elem[0].nodeName !== 'A')) {
elem.attr('role', 'button');
}
}
};
}])
Expand Down
9 changes: 9 additions & 0 deletions test/ngAria/ariaSpec.js
Expand Up @@ -143,6 +143,15 @@ describe('$aria', function() {
describe('roles for custom inputs', function() {
beforeEach(injectScopeAndCompiler);

it('should add missing role="button" to custom input', function() {
compileInput('<div ng-click="someFunction()"></div>');
expect(element.attr('role')).toBe('button');
});
it('should not add role="button" to anchor', function() {
compileInput('<a ng-click="someFunction()"></a>');
expect(element.attr('role')).not.toBe('button');
});

it('should add missing role="checkbox" to custom input', function() {
scope.$apply('val = true');
compileInput('<div type="checkbox" ng-model="val"></div>');
Expand Down

0 comments on commit b420186

Please sign in to comment.