-
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
Select option empty value regression in 15.0.0-rc.1 #6219
Comments
I don't know why jsbin doesn't save my changes... |
html for 0.14.7 <script src="https://fb.me/react-with-addons-0.14.7.min.js"></script>
<script src="https://fb.me/react-dom-0.14.7.min.js"></script>
<div id="app"></div> html for 15.0.0-rc.1 <script src="https://fb.me/react-with-addons-15.0.0-rc.1.min.js"></script>
<script src="https://fb.me/react-dom-15.0.0-rc.1.min.js"></script>
<div id="app"></div> jsx for both function log(e) {
console.log(e.target.value);
}
const Select = (
<select onChange={log}>
<option value="">empty</option>
<option value="filled">filled</option>
</select>
);
ReactDOM.render(
Select,
document.getElementById("app")
); |
I want to fix this. Can you point me to right place? I believe this is ReactDOM issue because Virtual DOM node looks ok. |
Yeah, I spent a few minutes looking for the PR that I suspect is responsible for this, but don't see it at the moment. Without having actually dug into the code, my intuition is to look at https://github.com/facebook/react/blob/master/src/renderers/dom/client/wrappers/ReactDOMSelect.js and https://github.com/facebook/react/blob/master/src/renderers/dom/client/wrappers/ReactDOMOption.js But don't rely on those tips too heavily, I don't want to send you off on a wild goose chase. |
I believe this commit introduces the bug (changes to file This code is responsible for setting attributes to the nodes being created. It's not a straightforward fix: It's questionable whether the current behavior is correct. Basically it checks whether the attribute is classified as The But, for example, the
The thing is, when the abovementioned check is done, before Above all that, this behavior (returning Anyway, to summarize, This PR #6228 fixes the issue. |
#1510 (comment) and #6119. However, it should be noted that this bug applies to cc @spicyj |
@syranide
In other cases though, as I understand it, only attributes classified as So we either handle the |
@everdimension There's semantic/technical differences between |
yep |
Ok, I agree. I thought that perhaps not setting empty In that case it may be a good idea to have something like For now I updated the pull request to handle all |
One can put |
FWIW, if you mount into something that was server side rendered, you get the
A potential solution here would be to stop treating |
@chicoxyzzy value="" is permitted only for handful of elements according to HTML spec, you can use data-* custom attributes. https://developer.mozilla.org/en/docs/Web/Guide/HTML/Using_data_attributes |
React 0.14.7:
<option value="">empty</option>
emits empty string on changehttp://jsbin.com/pisita/10/edit?html,js,console,output
React 15.0.0-rc.1
<option value="">empty</option>
emits string with value "empty" on changehttp://jsbin.com/bemaze/12/edit?html,js,console,output
This is because React 15.0.0-rc.1 cuts off
value=""
from option tagThe text was updated successfully, but these errors were encountered: