Skip to content

Commit a2c90aa

Browse files
committed
Merge pull request react#275 from spicyj/input-private
Make getChecked, getValue, handleChange private
2 parents e1c1d86 + 898621d commit a2c90aa

3 files changed

Lines changed: 13 additions & 22 deletions

File tree

src/dom/components/ReactDOMInput.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,16 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
5757
return !this._isChanging;
5858
},
5959

60-
getChecked: function() {
61-
return this.props.checked != null ? this.props.checked : this.state.checked;
62-
},
63-
64-
getValue: function() {
65-
// Cast `this.props.value` to a string so equality checks pass.
66-
return this.props.value != null ? '' + this.props.value : this.state.value;
67-
},
68-
6960
render: function() {
7061
// Clone `this.props` so we don't mutate the input.
7162
var props = merge(this.props);
7263

73-
props.checked = this.getChecked();
74-
props.value = this.getValue();
75-
props.onChange = this.handleChange;
64+
props.checked =
65+
this.props.checked != null ? this.props.checked : this.state.checked;
66+
// Cast `this.props.value` to a string so equality checks pass.
67+
props.value =
68+
this.props.value != null ? '' + this.props.value : this.state.value;
69+
props.onChange = this._handleChange;
7670

7771
return input(props, this.props.children);
7872
},
@@ -96,7 +90,7 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
9690
}
9791
},
9892

99-
handleChange: function(event) {
93+
_handleChange: function(event) {
10094
var returnValue;
10195
if (this.props.onChange) {
10296
this._isChanging = true;

src/dom/components/ReactDOMSelect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
116116
// Clone `this.props` so we don't mutate the input.
117117
var props = merge(this.props);
118118

119-
props.onChange = this.handleChange;
119+
props.onChange = this._handleChange;
120120
props.value = null;
121121

122122
return select(props, this.props.children);
@@ -126,7 +126,7 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
126126

127127
componentDidUpdate: updateOptions,
128128

129-
handleChange: function(event) {
129+
_handleChange: function(event) {
130130
var returnValue;
131131
if (this.props.onChange) {
132132
this._isChanging = true;

src/dom/components/ReactDOMTextarea.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
9393
return !this._isChanging;
9494
},
9595

96-
getValue: function() {
97-
return this.props.value != null ? this.props.value : this.state.value;
98-
},
99-
10096
render: function() {
10197
// Clone `this.props` so we don't mutate the input.
10298
var props = merge(this.props);
@@ -106,8 +102,9 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
106102
'`dangerouslySetInnerHTML` does not make sense on <textarea>.'
107103
);
108104

109-
props.value = this.getValue();
110-
props.onChange = this.handleChange;
105+
props.value =
106+
this.props.value != null ? this.props.value : this.state.value;
107+
props.onChange = this._handleChange;
111108

112109
// Always set children to the same thing. In IE9, the selection range will
113110
// get reset if `textContent` is mutated.
@@ -124,7 +121,7 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
124121
}
125122
},
126123

127-
handleChange: function(event) {
124+
_handleChange: function(event) {
128125
var returnValue;
129126
if (this.props.onChange) {
130127
this._isChanging = true;

0 commit comments

Comments
 (0)