Merge pull request #3402 from vkramskikh/fix-empty-selects-with-value

Fix for empty <select> elements with value
This commit is contained in:
Paul O’Shannessy
2015-03-13 18:04:57 -07:00
2 changed files with 19 additions and 1 deletions
@@ -89,7 +89,9 @@ function updateOptions(component, propValue) {
return;
}
}
options[0].selected = true;
if (options.length) {
options[0].selected = true;
}
}
}
@@ -43,6 +43,14 @@ describe('ReactDOMSelect', function() {
expect(node.value).toEqual('giraffe');
});
it('should not throw with `defaultValue` and without children', function() {
var stub = <select defaultValue="dummy"></select>;
expect(() => {
ReactTestUtils.renderIntoDocument(stub);
}).not.toThrow();
});
it('should not control when using `defaultValue`', function() {
var stub =
<select defaultValue="giraffe">
@@ -100,6 +108,14 @@ describe('ReactDOMSelect', function() {
expect(node.value).toEqual('gorilla');
});
it('should not throw with `value` and without children', function() {
var stub = <select value="dummy"></select>;
expect(() => {
ReactTestUtils.renderIntoDocument(stub);
}).not.toThrow();
});
it('should allow setting `value` with multiple', function() {
var stub =
<select multiple={true} value={['giraffe', 'gorilla']}>