Make sure DOM components work in JSDOM
Paul O’Shannessy committed
Oct 15, 2013 at 11:37 UTC
087c2afed191ddfe1161fa38668d4f5f583f8a61
2 files changed
+6
-2
src/dom/components/ReactDOMInput.js
+3
-1
@@ -103,7 +103,9 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
103
104
var value = this.getValue();
105
if (value != null) {
106
- DOMPropertyOperations.setValueForProperty(rootNode, 'value', value);
106
+ // Cast `value` to a string to ensure the value is set correctly. While
107
+ // browsers typically do this as necessary, jsdom doesn't.
108
+ DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
109
}
110
},
111
src/dom/components/ReactDOMTextarea.js
+3
-1
@@ -113,7 +113,9 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
113
componentDidUpdate: function(prevProps, prevState, rootNode) {
114
var value = this.getValue();
115
if (value != null) {
116
- DOMPropertyOperations.setValueForProperty(rootNode, 'value', value);
116
+ // Cast `value` to a string to ensure the value is set correctly. While
117
+ // browsers typically do this as necessary, jsdom doesn't.
118
+ DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
119
}
120
},
121