File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ var DropdownButton = React.createClass({
2222 href : React . PropTypes . string ,
2323 onClick : React . PropTypes . func ,
2424 onSelect : React . PropTypes . func ,
25- navItem : React . PropTypes . bool
25+ navItem : React . PropTypes . bool ,
26+ noCaret : React . PropTypes . bool
2627 } ,
2728
2829 render : function ( ) {
@@ -31,6 +32,9 @@ var DropdownButton = React.createClass({
3132 var renderMethod = this . props . navItem ?
3233 'renderNavItem' : 'renderButtonGroup' ;
3334
35+ var caret = this . props . noCaret ?
36+ null : ( < span className = "caret" /> ) ;
37+
3438 return this [ renderMethod ] ( [
3539 < Button
3640 { ...this . props }
@@ -44,7 +48,7 @@ var DropdownButton = React.createClass({
4448 pullRight = { null }
4549 dropup = { null } >
4650 { this . props . title } { ' ' }
47- < span className = " caret" />
51+ { caret }
4852 </ Button > ,
4953 < DropdownMenu
5054 ref = "menu"
Original file line number Diff line number Diff line change @@ -177,4 +177,30 @@ describe('DropdownButton', function () {
177177 assert . ok ( button . lastChild . className . match ( / \b c a r e t \b / ) ) ;
178178 assert . equal ( button . innerText . trim ( ) , 'Title' ) ;
179179 } ) ;
180+
181+ it ( 'should render a caret by default' , function ( ) {
182+ instance = ReactTestUtils . renderIntoDocument (
183+ < DropdownButton title = "Title" >
184+ < MenuItem eventKey = "1" > MenuItem 1 content</ MenuItem >
185+ < MenuItem eventKey = "2" > MenuItem 2 content</ MenuItem >
186+ </ DropdownButton >
187+ ) ;
188+
189+ var button = ReactTestUtils . findRenderedComponentWithType ( instance , Button ) . getDOMNode ( ) ;
190+ var carets = button . getElementsByClassName ( 'caret' ) ;
191+ assert . equal ( carets . length , 1 ) ;
192+ } ) ;
193+
194+ it ( 'should not render a caret if noCaret prop is given' , function ( ) {
195+ instance = ReactTestUtils . renderIntoDocument (
196+ < DropdownButton title = "Title" noCaret >
197+ < MenuItem eventKey = "1" > MenuItem 1 content</ MenuItem >
198+ < MenuItem eventKey = "2" > MenuItem 2 content</ MenuItem >
199+ </ DropdownButton >
200+ ) ;
201+
202+ var button = ReactTestUtils . findRenderedComponentWithType ( instance , Button ) . getDOMNode ( ) ;
203+ var carets = button . getElementsByClassName ( 'caret' ) ;
204+ assert . equal ( carets . length , 0 ) ;
205+ } ) ;
180206} ) ;
You can’t perform that action at this time.
0 commit comments