mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #3402 from vkramskikh/fix-empty-selects-with-value
Fix for empty <select> elements with value
This commit is contained in:
@@ -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']}>
|
||||
|
||||
Reference in New Issue
Block a user