Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d049ebf76facad148b7d46dddf24024870c7658a
Choose a base ref
..
head repository: facebook/react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1e8a3e8b52700fce2a245c959b926ecde83a8528
Choose a head ref
Showing with 12 additions and 2 deletions.
  1. +3 −2 src/renderers/dom/client/wrappers/ReactDOMTextarea.js
  2. +9 −0 src/renderers/dom/client/wrappers/__tests__/ReactDOMTextarea-test.js
5 changes: 3 additions & 2 deletions src/renderers/dom/client/wrappers/ReactDOMTextarea.js
Original file line number Diff line number Diff line change
@@ -100,10 +100,11 @@ var ReactDOMTextarea = {

// The value can be a boolean or object so that's why it's
// forced to be a string.
defaultValue = '' + (value != null ? value : defaultValue);
var nativeProps = Object.assign({}, props, {
defaultValue: '' + (value != null ? value : defaultValue),
defaultValue: defaultValue,
value: undefined,
children: undefined,
children: defaultValue,
onChange: inst._wrapperState.onChange,
});

Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ var emptyFunction = require('emptyFunction');
describe('ReactDOMTextarea', function() {
var React;
var ReactDOM;
var ReactDOMServer;
var ReactLink;
var ReactTestUtils;

@@ -24,6 +25,7 @@ describe('ReactDOMTextarea', function() {
beforeEach(function() {
React = require('React');
ReactDOM = require('ReactDOM');
ReactDOMServer = require('ReactDOMServer');
ReactLink = require('ReactLink');
ReactTestUtils = require('ReactTestUtils');

@@ -113,6 +115,13 @@ describe('ReactDOMTextarea', function() {
expect(node.value).toEqual('gorilla');
});

it('should take `defaultValue` when changing to uncontrolled input', function() {
var image = ReactDOMServer.renderToString(<textarea defaultValue="1" />);
var div = document.createElement('div');
div.innerHTML = image;
expect(div.firstChild.innerHTML).toBe('1');
});

it('should allow setting `value` to `true`', function() {
var container = document.createElement('div');
var stub = <textarea value="giraffe" onChange={emptyFunction} />;