diff --git a/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js b/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js index 5013519a27050..9d179ac35cee0 100644 --- a/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js +++ b/src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js @@ -760,4 +760,25 @@ describe('ReactDOMInput', function() { ); expect(input.value).toBe('hi'); }); + + it('does not raise a validation warning when it switches types', function() { + var Input = React.createClass({ + getInitialState() { + return { type: 'number', value: 1000 }; + }, + render() { + var { value, type } = this.state; + return ( {}} type={type} value={value} />); + }, + }); + + var input = ReactTestUtils.renderIntoDocument(); + var node = ReactDOM.findDOMNode(input); + + // If the value is set before the type, a validation warning will raise and + // the value will not be assigned. + input.setState({ type: 'text', value: 'Test' }); + expect(node.value).toEqual('Test'); + }); + }); diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index 476991c83392a..8f6cde450727d 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -900,7 +900,6 @@ ReactDOMComponent.Mixin = { nextProps = ReactDOMButton.getHostProps(this, nextProps); break; case 'input': - ReactDOMInput.updateWrapper(this); lastProps = ReactDOMInput.getHostProps(this, lastProps); nextProps = ReactDOMInput.getHostProps(this, nextProps); break; @@ -913,7 +912,6 @@ ReactDOMComponent.Mixin = { nextProps = ReactDOMSelect.getHostProps(this, nextProps); break; case 'textarea': - ReactDOMTextarea.updateWrapper(this); lastProps = ReactDOMTextarea.getHostProps(this, lastProps); nextProps = ReactDOMTextarea.getHostProps(this, nextProps); break; @@ -928,10 +926,21 @@ ReactDOMComponent.Mixin = { context ); - if (this._tag === 'select') { - // value update needs to occur after