@samitouri / QOS-React-2 / commits / b9c132e58a

Removes value from rendered attributes of textarea

Jon Beebe committed Jun 18, 2014 at 14:34 UTC b9c132e58ae9490747bbb09de0e76455af4f0a7d
2 files changed +10 -4
src/browser/ui/dom/components/ReactDOMTextarea.js
+2 -4
@@ -88,8 +88,7 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
88 // `textContent` (unnecessary since we update value).
89 // The initial value can be a boolean or object so that's why it's
90 // forced to be a string.
91 - initialValue: '' + (value != null ? value : defaultValue),
92 - value: defaultValue
91 + initialValue: '' + (value != null ? value : defaultValue)
92 };
93 },
94
@@ -101,7 +100,6 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
100 render: function() {
101 // Clone `this.props` so we don't mutate the input.
102 var props = merge(this.props);
104 - var value = LinkedValueUtils.getValue(this);
103
104 invariant(
105 props.dangerouslySetInnerHTML == null,
@@ -109,7 +107,7 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
107 );
108
109 props.defaultValue = null;
112 - props.value = value != null ? value : this.state.value;
110 + props.value = null;
111 props.onChange = this._handleChange;
112
113 // Always set children to the same thing. In IE9, the selection range will
src/browser/ui/dom/components/__tests__/ReactDOMTextarea-test.js
+8
@@ -85,6 +85,14 @@ describe('ReactDOMTextarea', function() {
85 expect(node.value).toBe('foobar');
86 });
87
88 + it('should not render value as an attribute', function() {
89 + var stub = <textarea value="giraffe" />;
90 + stub = renderTextarea(stub);
91 + var node = stub.getDOMNode();
92 +
93 + expect(node.getAttribute('value')).toBe(null);
94 + });
95 +
96 it('should display `value` of number 0', function() {
97 var stub = <textarea value={0} />;
98 stub = renderTextarea(stub);