* @param {ReactDOMComponent} inst * @param {boolean} multiple * @param {*} propValue A stringable (with `multiple`, a list of stringables). * @private
(inst, multiple, propValue)
| 8250 | * @private |
| 8251 | */ |
| 8252 | function updateOptions(inst, multiple, propValue) { |
| 8253 | var selectedValue, i; |
| 8254 | var options = ReactDOMComponentTree.getNodeFromInstance(inst).options; |
| 8255 | |
| 8256 | if (multiple) { |
| 8257 | selectedValue = {}; |
| 8258 | for (i = 0; i < propValue.length; i++) { |
| 8259 | selectedValue['' + propValue[i]] = true; |
| 8260 | } |
| 8261 | for (i = 0; i < options.length; i++) { |
| 8262 | var selected = selectedValue.hasOwnProperty(options[i].value); |
| 8263 | if (options[i].selected !== selected) { |
| 8264 | options[i].selected = selected; |
| 8265 | } |
| 8266 | } |
| 8267 | } else { |
| 8268 | // Do not set `select.value` as exact behavior isn't consistent across all |
| 8269 | // browsers for all cases. |
| 8270 | selectedValue = '' + propValue; |
| 8271 | for (i = 0; i < options.length; i++) { |
| 8272 | if (options[i].value === selectedValue) { |
| 8273 | options[i].selected = true; |
| 8274 | return; |
| 8275 | } |
| 8276 | } |
| 8277 | if (options.length) { |
| 8278 | options[0].selected = true; |
| 8279 | } |
| 8280 | } |
| 8281 | } |
| 8282 | |
| 8283 | /** |
| 8284 | * Implements a <select> native component that allows optionally setting the |
no outgoing calls
no test coverage detected
searching dependent graphs…