Make getChecked, getValue, handleChange private

Test Plan: grunt test, enter text in ballmer-peak example without any JS errors.
This commit is contained in:
Ben Alpert 2013-08-17 17:04:00 -07:00
parent 1f8ef4c903
commit 898621d0a1
3 changed files with 13 additions and 22 deletions

View File

@ -57,22 +57,16 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
return !this._isChanging;
},
getChecked: function() {
return this.props.checked != null ? this.props.checked : this.state.checked;
},
getValue: function() {
// Cast `this.props.value` to a string so equality checks pass.
return this.props.value != null ? '' + this.props.value : this.state.value;
},
render: function() {
// Clone `this.props` so we don't mutate the input.
var props = merge(this.props);
props.checked = this.getChecked();
props.value = this.getValue();
props.onChange = this.handleChange;
props.checked =
this.props.checked != null ? this.props.checked : this.state.checked;
// Cast `this.props.value` to a string so equality checks pass.
props.value =
this.props.value != null ? '' + this.props.value : this.state.value;
props.onChange = this._handleChange;
return input(props, this.props.children);
},
@ -96,7 +90,7 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
}
},
handleChange: function(event) {
_handleChange: function(event) {
var returnValue;
if (this.props.onChange) {
this._isChanging = true;

View File

@ -118,7 +118,7 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
// Clone `this.props` so we don't mutate the input.
var props = merge(this.props);
props.onChange = this.handleChange;
props.onChange = this._handleChange;
props.value = null;
return select(props, this.props.children);
@ -128,7 +128,7 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
componentDidUpdate: updateOptions,
handleChange: function(event) {
_handleChange: function(event) {
var returnValue;
if (this.props.onChange) {
this._isChanging = true;

View File

@ -93,10 +93,6 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
return !this._isChanging;
},
getValue: function() {
return this.props.value != null ? this.props.value : this.state.value;
},
render: function() {
// Clone `this.props` so we don't mutate the input.
var props = merge(this.props);
@ -106,8 +102,9 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
'`dangerouslySetInnerHTML` does not make sense on <textarea>.'
);
props.value = this.getValue();
props.onChange = this.handleChange;
props.value =
this.props.value != null ? this.props.value : this.state.value;
props.onChange = this._handleChange;
// Always set children to the same thing. In IE9, the selection range will
// get reset if `textContent` is mutated.
@ -124,7 +121,7 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
}
},
handleChange: function(event) {
_handleChange: function(event) {
var returnValue;
if (this.props.onChange) {
this._isChanging = true;