Satisfy Flow by assuming value is an array for multi-select
Sebastian Markbage committed
Nov 17, 2016 at 17:28 UTC
e962e97f752d839e0d4ba5d2c232e8f023e8b3f5
1 file changed
+5
-4
src/renderers/dom/fiber/wrappers/ReactDOMFiberSelect.js
+5
-4
@@ -68,13 +68,14 @@ function checkSelectPropTypes(inst, props) {
68
}
69
}
70
71
-function updateOptions(inst : Fiber, multiple : boolean, propValue : string | Array<string>) {
71
+function updateOptions(inst : Fiber, multiple : boolean, propValue : any) {
72
var options = ReactDOMComponentTree.getNodeFromInstance(inst).options;
73
74
if (multiple) {
75
+ let selectedValues = (propValue : Array<string>);
76
let selectedValue = {};
76
- for (let i = 0; i < propValue.length; i++) {
77
- selectedValue['' + propValue[i]] = true;
77
+ for (let i = 0; i < selectedValues.length; i++) {
78
+ selectedValue['' + selectedValues[i]] = true;
79
}
80
for (let i = 0; i < options.length; i++) {
81
var selected = selectedValue.hasOwnProperty(options[i].value);
@@ -85,7 +86,7 @@ function updateOptions(inst : Fiber, multiple : boolean, propValue : string | Ar
86
} else {
87
// Do not set `select.value` as exact behavior isn't consistent across all
88
// browsers for all cases.
88
- let selectedValue = '' + propValue;
89
+ let selectedValue = '' + (propValue : string);
90
for (let i = 0; i < options.length; i++) {
91
if (options[i].value === selectedValue) {
92
options[i].selected = true;