Skip to content

Commit a3f9008

Browse files
committed
Handle multiple children in <Badge>. Fixes react-bootstrap#532
1 parent a07ea20 commit a3f9008

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/Badge.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const Badge = React.createClass({
1010

1111
hasContent() {
1212
return ValidComponentChildren.hasValidComponent(this.props.children) ||
13+
(React.Children.count(this.props.children) > 1) ||
1314
(typeof this.props.children === 'string') ||
1415
(typeof this.props.children === 'number');
1516
},

test/BadgeSpec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ describe('Badge', function () {
3131
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
3232
});
3333

34+
it('Should have a badge using a a mix of content', function () {
35+
let count = 42;
36+
let instance = ReactTestUtils.renderIntoDocument(
37+
<Badge>
38+
£{count}
39+
</Badge>
40+
);
41+
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
42+
});
43+
3444
it('Should have a badge class pulled right', function () {
3545
let instance = ReactTestUtils.renderIntoDocument(
3646
<Badge pullRight>

0 commit comments

Comments
 (0)