Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(subheader): respect custom set aria role
Browse files Browse the repository at this point in the history
references #216
  • Loading branch information
rschmukler committed Sep 7, 2014
1 parent 9d3822c commit 633eea0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/components/subheader/subheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ function materialSubheaderDirective() {
return {
restrict: 'E',
compile: function($el, $attr) {
$el.attr({
'role' : Constant.ARIA.ROLE.HEADING
});
if(!$attr.role) {
$el.attr({
'role' : Constant.ARIA.ROLE.HEADING
});
}
}
};
}
7 changes: 6 additions & 1 deletion src/components/subheader/subheader.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
describe('materialSubheader', function() {
beforeEach(module('material.components.subheader'));

it('should set aria role', inject(function($compile, $rootScope) {
it('should set default aria role', inject(function($compile, $rootScope) {
var $el = $compile('<material-subheader>Hello world!</material-header>')($rootScope);
expect($el.attr('role')).toEqual('heading');
}));

it('should respect a custom set aria role', inject(function($compile, $rootScope) {
var $el = $compile('<material-subheader role="button">Hello world!</material-header>')($rootScope);
expect($el.attr('role')).toEqual('button');
}));

it('should preserve content', inject(function($compile, $rootScope) {
var $scope = $rootScope.$new();
$scope.to = 'world';
Expand Down

0 comments on commit 633eea0

Please sign in to comment.