Skip to content

Commit 035e553

Browse files
committedNov 16, 2015
[fixed] navbar-default not added for custom styles
1 parent 0c48c60 commit 035e553

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed
 

‎src/Navbar.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,16 @@ let Navbar = React.createClass({
152152
props.role = 'navigation';
153153
}
154154

155-
const classes = tbsUtils.getClassSet(this.props);
155+
if (inverse) {
156+
props.bsStyle = INVERSE;
157+
}
158+
159+
const classes = tbsUtils.getClassSet(props);
156160

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

161-
// handle built-in styles manually to provide the convenience `inverse` prop
162-
classes[tbsUtils.prefix(this.props, INVERSE)] = inverse;
163-
classes[tbsUtils.prefix(this.props, DEFAULT)] = !inverse;
164-
165165
return (
166166
<ComponentClass {...props} className={classNames(className, classes)}>
167167
<Grid fluid={fluid}>

‎test/NavbarSpec.js

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Nav from '../src/Nav';
66
import Navbar from '../src/Navbar';
77

88
import { getOne, shouldWarn } from './helpers';
9+
import utils from '../src/utils/bootstrapUtils';
910

1011
describe('Navbar', () => {
1112

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

60+
it('Should not add default class along with custom styles', () => {
61+
utils.addStyle(Navbar, ['custom']);
62+
63+
let instance = ReactTestUtils.renderIntoDocument(
64+
<Navbar bsStyle='custom' />
65+
);
66+
67+
expect(() => ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'navbar-default'))
68+
.to.throw();
69+
});
70+
5971
it('Should add fluid variation class', () => {
6072
let instance = ReactTestUtils.renderIntoDocument(
6173
<Navbar fluid />

0 commit comments

Comments
 (0)
Please sign in to comment.