diff --git a/src/components/subheader/subheader.js b/src/components/subheader/subheader.js index 1fd4a21e5c0..a219519e2dc 100644 --- a/src/components/subheader/subheader.js +++ b/src/components/subheader/subheader.js @@ -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 + }); + } } }; } diff --git a/src/components/subheader/subheader.spec.js b/src/components/subheader/subheader.spec.js index 1e4f9e610f0..a884a0b25c9 100644 --- a/src/components/subheader/subheader.spec.js +++ b/src/components/subheader/subheader.spec.js @@ -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('Hello world!')($rootScope); expect($el.attr('role')).toEqual('heading'); })); + it('should respect a custom set aria role', inject(function($compile, $rootScope) { + var $el = $compile('Hello world!')($rootScope); + expect($el.attr('role')).toEqual('button'); + })); + it('should preserve content', inject(function($compile, $rootScope) { var $scope = $rootScope.$new(); $scope.to = 'world';