From a3f90082838c5e4228444d399f9bf9753608e385 Mon Sep 17 00:00:00 2001 From: Glen Mailer Date: Sun, 19 Apr 2015 21:41:16 +0100 Subject: [PATCH] Handle multiple children in . Fixes #532 --- src/Badge.js | 1 + test/BadgeSpec.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/Badge.js b/src/Badge.js index 910d6d3603..4b72c11aea 100644 --- a/src/Badge.js +++ b/src/Badge.js @@ -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'); }, diff --git a/test/BadgeSpec.js b/test/BadgeSpec.js index 2deb75c8f5..a170e35eea 100644 --- a/test/BadgeSpec.js +++ b/test/BadgeSpec.js @@ -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( + + £{count} + + ); + assert.ok(instance.getDOMNode().className.match(/\bbadge\b/)); + }); + it('Should have a badge class pulled right', function () { let instance = ReactTestUtils.renderIntoDocument(