Skip to content

Commit

Permalink
Make sure DOM components work in JSDOM
Browse files Browse the repository at this point in the history
  • Loading branch information
zpao committed Oct 15, 2013
1 parent b0645bd commit 087c2af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/dom/components/ReactDOMInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},

Expand Down
4 changes: 3 additions & 1 deletion src/dom/components/ReactDOMTextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},

Expand Down

0 comments on commit 087c2af

Please sign in to comment.