Skip to content

Commit

Permalink
Fix ReactDOMFiberSelect to set the initial values
Browse files Browse the repository at this point in the history
I forgot that the normal properties route doesn't do this. We also have
to make sure that the order is 1) insert children (options), 2) set
multiple 3) update the options.
  • Loading branch information
sebmarkbage committed Nov 18, 2016
1 parent 6741703 commit 11db613
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
17 changes: 0 additions & 17 deletions scripts/fiber/tests-failing.txt
Expand Up @@ -88,23 +88,6 @@ src/renderers/dom/shared/eventPlugins/__tests__/SimpleEventPlugin-test.js
src/renderers/dom/shared/wrappers/__tests__/ReactDOMInput-test.js
* should control a value in reentrant events

src/renderers/dom/shared/wrappers/__tests__/ReactDOMOption-test.js
* should allow ignoring `value` on option

src/renderers/dom/shared/wrappers/__tests__/ReactDOMSelect-test.js
* should allow setting `defaultValue`
* should not control when using `defaultValue`
* should allow setting `defaultValue` with multiple
* should allow setting `value`
* should allow setting `value` with multiple
* should not select other options automatically
* should allow setting `value` with `objectToString`
* should allow switching to multiple
* should allow switching from multiple
* should remember value when switching to uncontrolled
* should not control defaultValue if readding options
* should select grandchild options nested inside an optgroup

src/renderers/dom/stack/client/__tests__/ReactDOM-test.js
* throws in render() if the mount callback is not a function
* throws in render() if the update callback is not a function
Expand Down
13 changes: 13 additions & 0 deletions scripts/fiber/tests-passing.txt
Expand Up @@ -831,18 +831,31 @@ src/renderers/dom/shared/wrappers/__tests__/ReactDOMOption-test.js
* should ignore null/undefined/false children without warning
* should be able to use dangerouslySetInnerHTML on option
* should set attribute for empty value
* should allow ignoring `value` on option

src/renderers/dom/shared/wrappers/__tests__/ReactDOMSelect-test.js
* should allow setting `defaultValue`
* should not throw with `defaultValue` and without children
* should not control when using `defaultValue`
* should allow setting `defaultValue` with multiple
* should allow setting `value`
* should not throw with `value` and without children
* should allow setting `value` with multiple
* should not select other options automatically
* should reset child options selected when they are changed and `value` is set
* should allow setting `value` with `objectToString`
* should allow switching to multiple
* should allow switching from multiple
* should remember value when switching to uncontrolled
* should remember updated value when switching to uncontrolled
* should support server-side rendering
* should support server-side rendering with defaultValue
* should support server-side rendering with multiple
* should not control defaultValue if readding options
* should refresh state on change
* should warn if value and defaultValue props are specified
* should be able to safely remove select onChange
* should select grandchild options nested inside an optgroup

src/renderers/dom/shared/wrappers/__tests__/ReactDOMTextarea-test.js
* should allow setting `defaultValue`
Expand Down
7 changes: 7 additions & 0 deletions src/renderers/dom/fiber/wrappers/ReactDOMFiberSelect.js
Expand Up @@ -153,6 +153,13 @@ var ReactDOMSelect = {
);
didWarnValueDefaultValue = true;
}

node.multiple = Boolean(props.multiple);
if (value != null) {
updateOptions(node, Boolean(props.multiple), value);
} else if (props.defaultValue != null) {
updateOptions(node, Boolean(props.multiple), props.defaultValue);
}
},

postUpdateWrapper: function(element : Element, props : Object) {
Expand Down

0 comments on commit 11db613

Please sign in to comment.