Skip to content

Commit

Permalink
Handle multiple children in <Badge>. Fixes react-bootstrap#532
Browse files Browse the repository at this point in the history
  • Loading branch information
glenjamin committed Apr 19, 2015
1 parent a07ea20 commit a3f9008
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const Badge = React.createClass({

hasContent() {
return ValidComponentChildren.hasValidComponent(this.props.children) ||
(React.Children.count(this.props.children) > 1) ||
(typeof this.props.children === 'string') ||
(typeof this.props.children === 'number');
},
Expand Down
10 changes: 10 additions & 0 deletions test/BadgeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ describe('Badge', function () {
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
});

it('Should have a badge using a a mix of content', function () {
let count = 42;
let instance = ReactTestUtils.renderIntoDocument(
<Badge>
£{count}
</Badge>
);
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
});

it('Should have a badge class pulled right', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Badge pullRight>
Expand Down

0 comments on commit a3f9008

Please sign in to comment.