Merge pull request #1716 from somethingkindawierd/master

Removes value attribute from rendered html of textarea
This commit is contained in:
Cheng Lou 2014-06-24 19:14:19 -07:00
commit d52bebd07b
2 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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" onChange={emptyFunction} />;
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);