Skip to content

Commit

Permalink
[fixed] navbar-default not added for custom styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Nov 16, 2015
1 parent 0c48c60 commit 035e553
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ let Navbar = React.createClass({
props.role = 'navigation';
}

const classes = tbsUtils.getClassSet(this.props);
if (inverse) {
props.bsStyle = INVERSE;
}

const classes = tbsUtils.getClassSet(props);

classes[tbsUtils.prefix(this.props, 'fixed-top')] = fixedTop;
classes[tbsUtils.prefix(this.props, 'fixed-bottom')] = fixedBottom;
classes[tbsUtils.prefix(this.props, 'static-top')] = staticTop;

// handle built-in styles manually to provide the convenience `inverse` prop
classes[tbsUtils.prefix(this.props, INVERSE)] = inverse;
classes[tbsUtils.prefix(this.props, DEFAULT)] = !inverse;

return (
<ComponentClass {...props} className={classNames(className, classes)}>
<Grid fluid={fluid}>
Expand Down
12 changes: 12 additions & 0 deletions test/NavbarSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Nav from '../src/Nav';
import Navbar from '../src/Navbar';

import { getOne, shouldWarn } from './helpers';
import utils from '../src/utils/bootstrapUtils';

describe('Navbar', () => {

Expand Down Expand Up @@ -56,6 +57,17 @@ describe('Navbar', () => {
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'navbar-inverse'));
});

it('Should not add default class along with custom styles', () => {
utils.addStyle(Navbar, ['custom']);

let instance = ReactTestUtils.renderIntoDocument(
<Navbar bsStyle='custom' />
);

expect(() => ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'navbar-default'))
.to.throw();
});

it('Should add fluid variation class', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Navbar fluid />
Expand Down

0 comments on commit 035e553

Please sign in to comment.