-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes initial option select #5362
Conversation
c349ff5
to
a04eb1d
Compare
@yiminghe updated the pull request. |
Looks good to me. Will leave it open for a day or two so everyone can take a look before we merge. |
@@ -41,31 +41,38 @@ var ReactDOMOption = { | |||
// or missing (e.g., for <datalist>), we don't change props.selected | |||
var selected = null; | |||
if (selectValue != null) { | |||
var value; | |||
if ('value' in props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
props.value != null
please – we treat null and undefined the same as omitted props for all DOM components.
We should call getNativeProps and mountWrapper in the same order for all components – it is too confusing to call getNativeProps first in some cases and mountWrapper first in other cases. |
Yes, I also feel weird for option to have a different order from others, then we have to call flattenChildren twice if value is omitted.... |
@yiminghe updated the pull request. |
e80f3cd
to
ce5fc92
Compare
@yiminghe updated the pull request. |
If we warn inside flattenChildren, and flattenChildren gets called twice, it seems like we would warn twice, right? We might want to move the warning logic out of flattenChildren. Also, let's squash into the two commits into a single commit before merging. Otherwise, looks good to me. @spicyj? |
Yeah. Can we just set a global flag so that we only warn once? |
ce5fc92
to
da204c9
Compare
Just as before, only warn in getNativeProps |
@yiminghe Maybe I'm missing something, but isn't flattenChildren also now being called in |
@yiminghe updated the pull request. |
@jimfb add a flag to only warn in getNativeProps |
@yiminghe Sorry we dropped the ball on this one, but I'd like to try to get this merged. Can you rebase and add a unit test to demonstrate that it only warns once, and then I think we can merge. |
Can you set a global (file-level) flag so that we only warn once, even if many children are the wrong type? Because we don't give information about the callsite it's not currently useful to warn many times. A similar example is here:
Then you don't even need the |
da204c9
to
3b9c8f2
Compare
updated as requested |
3b9c8f2
to
e4a6fea
Compare
} | ||
if (typeof child === 'string' || typeof child === 'number') { | ||
content += child; | ||
} else if(!didWarnInvalidOptionChildren) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit: missing space before (
e4a6fea
to
934cea4
Compare
@yiminghe updated the pull request. |
Thank you! |
(cherry picked from commit 904ee9a)
(cherry picked from commit 904ee9a)
make sure initial select
renders correctly.
Update is fine, because native
option.value
will get its content if value is absent