Removes value from rendered attributes of textarea

This commit is contained in:
Jon Beebe
2014-06-19 07:14:49 -05:00
parent 92e3384cd2
commit b9c132e58a
2 changed files with 10 additions and 4 deletions
@@ -88,8 +88,7 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
// `textContent` (unnecessary since we update value).
// The initial value can be a boolean or object so that's why it's
// forced to be a string.
initialValue: '' + (value != null ? value : defaultValue),
value: defaultValue
initialValue: '' + (value != null ? value : defaultValue)
};
},
@@ -101,7 +100,6 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
render: function() {
// Clone `this.props` so we don't mutate the input.
var props = merge(this.props);
var value = LinkedValueUtils.getValue(this);
invariant(
props.dangerouslySetInnerHTML == null,
@@ -109,7 +107,7 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
);
props.defaultValue = null;
props.value = value != null ? value : this.state.value;
props.value = null;
props.onChange = this._handleChange;
// Always set children to the same thing. In IE9, the selection range will
@@ -85,6 +85,14 @@ describe('ReactDOMTextarea', function() {
expect(node.value).toBe('foobar');
});
it('should not render value as an attribute', function() {
var stub = <textarea value="giraffe" />;
stub = renderTextarea(stub);
var node = stub.getDOMNode();
expect(node.getAttribute('value')).toBe(null);
});
it('should display `value` of number 0', function() {
var stub = <textarea value={0} />;
stub = renderTextarea(stub);