diff --git a/src/Navbar.js b/src/Navbar.js index 43d9951e51..b1ad1fc98e 100644 --- a/src/Navbar.js +++ b/src/Navbar.js @@ -39,7 +39,6 @@ const Navbar = React.createClass({ return { bsClass: 'navbar', bsStyle: 'default', - role: 'navigation', componentClass: 'nav', fixedTop: false, fixedBottom: false, @@ -109,6 +108,13 @@ const Navbar = React.createClass({ (brand || toggleButton || toggleNavKey != null) && !this.hasNavBrandChild(); + // will result in some false positives but that seems better + // than false negatives. strict `undefined` check allows explicit + // "nulling" of the role if the user really doesn't want one + if (props.role === undefined && ComponentClass !== 'nav') { + props.role = 'navigation'; + } + return ( diff --git a/test/NavbarSpec.js b/test/NavbarSpec.js index 36b2dcabac..4c483d3205 100644 --- a/test/NavbarSpec.js +++ b/test/NavbarSpec.js @@ -17,7 +17,16 @@ describe('Navbar', () => { let nav = ReactDOM.findDOMNode(instance); assert.equal(nav.nodeName, 'NAV'); assert.ok(nav.className.match(/\bnavbar\b/)); - assert.ok(nav.getAttribute('role'), 'navigation'); + assert.ok(!nav.getAttribute('role')); + }); + + it('Should add "navigation" role when not using a `