Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow removal of debug code in production builds #349

Merged
merged 1 commit into from
Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js/enhanced-switch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ var EnhancedSwitch = React.createClass({
if (!this.props.hasOwnProperty('checked') || this.props.checked == false) {
this.setState({switched: newSwitchedValue});
this.refs.checkbox.getDOMNode().checked = newSwitchedValue;
} else {
} else if (process.NODE_ENV !== 'production') {
var message = 'Cannot call set method while checked is defined as a property.';
console.error(message);
}
Expand Down
14 changes: 8 additions & 6 deletions src/js/floating-action-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ var RaisedButton = React.createClass({
},

componentDidMount: function() {
if (this.props.iconClassName && this.props.children) {
var warning = 'You have set both an iconClassName and a child icon. ' +
'It is recommended you use only one method when adding ' +
'icons to FloatingActionButtons.';
console.warn(warning);
if (process.NODE_ENV !== 'production') {
if (this.props.iconClassName && this.props.children) {
var warning = 'You have set both an iconClassName and a child icon. ' +
'It is recommended you use only one method when adding ' +
'icons to FloatingActionButtons.';
console.warn(warning);
}
}
},

Expand Down Expand Up @@ -107,4 +109,4 @@ var RaisedButton = React.createClass({

});

module.exports = RaisedButton;
module.exports = RaisedButton;
15 changes: 8 additions & 7 deletions src/js/icon-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ var IconButton = React.createClass({
if (this.props.tooltip) {
this._positionTooltip();
}

if (this.props.iconClassName && this.props.children) {
var warning = 'You have set both an iconClassName and a child icon. ' +
'It is recommended you use only one method when adding ' +
'icons to IconButtons.';
console.warn(warning);
if (process.NODE_ENV !== 'production') {
if (this.props.iconClassName && this.props.children) {
var warning = 'You have set both an iconClassName and a child icon. ' +
'It is recommended you use only one method when adding ' +
'icons to IconButtons.';
console.warn(warning);
}
}
},

Expand Down Expand Up @@ -119,4 +120,4 @@ var IconButton = React.createClass({

});

module.exports = IconButton;
module.exports = IconButton;
4 changes: 3 additions & 1 deletion src/js/input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ var Input = React.createClass({
},

componentDidMount: function() {
console.warn('Input has been deprecated. Please use TextField instead. See http://material-ui.com/#/components/text-fields');
if (process.NODE_ENV !== 'production') {
console.warn('Input has been deprecated. Please use TextField instead. See http://material-ui.com/#/components/text-fields');
}
},

render: function() {
Expand Down
8 changes: 4 additions & 4 deletions src/js/radio-button-group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ var RadioButtonGroup = React.createClass({
_updateRadioButtons: function(newSelection) {
if (this.state.numberCheckedRadioButtons == 0) {
this.setState({selected: newSelection});
} else {
var message = "Cannot select a different radio button while another radio button " +
"has the 'checked' property set to true.";
console.error(message);
} else if (process.NODE_ENV !== 'production') {
var message = "Cannot select a different radio button while another radio button " +
"has the 'checked' property set to true.";
console.error(message);
}
},

Expand Down
6 changes: 3 additions & 3 deletions src/js/text-field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ var TextField = React.createClass({
},

setErrorText: function(newErrorText) {
if (this.props.hasOwnProperty('errorText')) {
if (process.NODE_ENV !== 'production' && this.props.hasOwnProperty('errorText')) {
console.error('Cannot call TextField.setErrorText when errorText is defined as a property.');
} else if (this.isMounted()) {
this.setState({errorText: newErrorText});
}
},

setValue: function(newValue) {
if (this._isControlled()) {
if (process.NODE_ENV !== 'production' && this._isControlled()) {
console.error('Cannot call TextField.setValue when value or valueLink is defined as a property.');
} else if (this.isMounted()) {
this._getInputNode().value = newValue;
Expand Down Expand Up @@ -212,4 +212,4 @@ var TextField = React.createClass({

});

module.exports = TextField;
module.exports = TextField;