diff --git a/src/ProgressBar.js b/src/ProgressBar.js
index b91f0db408..c8de41f12d 100644
--- a/src/ProgressBar.js
+++ b/src/ProgressBar.js
@@ -28,41 +28,34 @@ const ProgressBar = React.createClass({
},
getPercentage(now, min, max) {
- let roundPrecision = 1000;
+ const roundPrecision = 1000;
return Math.round(((now - min) / (max - min) * 100) * roundPrecision) / roundPrecision;
},
render() {
- let classes = {
- progress: true
- };
-
- if (this.props.active) {
- classes['progress-striped'] = true;
- classes.active = true;
- } else if (this.props.striped) {
- classes['progress-striped'] = true;
+ if (this.props.isChild) {
+ return this.renderProgressBar();
}
- if (!ValidComponentChildren.hasValidComponent(this.props.children)) {
- if (!this.props.isChild) {
- return (
-
- {this.renderProgressBar()}
-
- );
- } else {
- return (
- this.renderProgressBar()
- );
- }
+ const classes = {
+ active: this.props.active,
+ progress: true,
+ 'progress-striped': this.props.active || this.props.striped
+ };
+
+ let content;
+
+ if (this.props.children) {
+ content = ValidComponentChildren.map(this.props.children, this.renderChildBar);
} else {
- return (
-
- {ValidComponentChildren.map(this.props.children, this.renderChildBar)}
-
- );
+ content = this.renderProgressBar();
}
+
+ return (
+
+ {content}
+
+ );
},
renderChildBar(child, index) {
@@ -73,28 +66,33 @@ const ProgressBar = React.createClass({
},
renderProgressBar() {
- let percentage = this.getPercentage(
- this.props.now,
- this.props.min,
- this.props.max
- );
+ const percentage = this.getPercentage(
+ this.props.now,
+ this.props.min,
+ this.props.max
+ );
let label;
if (typeof this.props.label === 'string') {
label = this.renderLabel(percentage);
- } else if (this.props.label) {
+ } else {
label = this.props.label;
}
if (this.props.srOnly) {
- label = this.renderScreenReaderOnlyLabel(label);
+ label = (
+
+ {label}
+
+ );
}
- let classes = this.getBsClassSet();
-
return (
-
);
- },
-
- renderScreenReaderOnlyLabel(label) {
- return (
-
- {label}
-
- );
}
});