Make submit button default value appear correctly
Fixes #473.
Ben Alpert committed
Nov 6, 2013 at 21:19 UTC
d5c2d5f291cf99e2827c71e2351b8c9207dcf503
2 files changed
+10
-1
src/dom/components/ReactDOMInput.js
+1
-1
@@ -55,7 +55,7 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
55
var defaultValue = this.props.defaultValue;
56
return {
57
checked: this.props.defaultChecked || false,
58
- value: defaultValue != null ? defaultValue : ''
58
+ value: defaultValue != null ? defaultValue : null
59
};
60
},
61
src/dom/components/__tests__/ReactDOMInput-test.js
+9
@@ -129,6 +129,15 @@ describe('ReactDOMInput', function() {
129
expect(node.value).toBe('0');
130
});
131
132
+ it('should not set a value for submit buttons unnecessarily', function() {
133
+ var stub = <input type="submit" />;
134
+ var node = renderTextInput(stub);
135
+
136
+ // The value shouldn't be '', or else the button will have no text; it
137
+ // should have the default "Submit" or "Submit Query" label
138
+ expect(node.hasAttribute('value')).toBe(false);
139
+ });
140
+
141
it('should control radio buttons', function() {
142
var RadioGroup = React.createClass({
143
render: function() {