diff --git a/src/dom/components/ReactDOMInput.js b/src/dom/components/ReactDOMInput.js index b38b4d1172..fce25d7cdc 100644 --- a/src/dom/components/ReactDOMInput.js +++ b/src/dom/components/ReactDOMInput.js @@ -103,7 +103,9 @@ var ReactDOMInput = ReactCompositeComponent.createClass({ var value = this.getValue(); if (value != null) { - DOMPropertyOperations.setValueForProperty(rootNode, 'value', value); + // Cast `value` to a string to ensure the value is set correctly. While + // browsers typically do this as necessary, jsdom doesn't. + DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value); } }, diff --git a/src/dom/components/ReactDOMTextarea.js b/src/dom/components/ReactDOMTextarea.js index b53df29302..9da6fac114 100644 --- a/src/dom/components/ReactDOMTextarea.js +++ b/src/dom/components/ReactDOMTextarea.js @@ -113,7 +113,9 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({ componentDidUpdate: function(prevProps, prevState, rootNode) { var value = this.getValue(); if (value != null) { - DOMPropertyOperations.setValueForProperty(rootNode, 'value', value); + // Cast `value` to a string to ensure the value is set correctly. While + // browsers typically do this as necessary, jsdom doesn't. + DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value); } },