-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Add better fallbacks to SelectElement.value #255
Conversation
Thanks, probably a good idea. Test is missing, though. And I'm also not entirely sure if that's the right place to change it. There isn't any defaulting in that method currently... |
If you're fine with breaking existing usages, I'd also favor doing it in To throw some standards at it, I think this sentence from the current W3C Recommendation applies:
The current W3C Proposed Recommendation also adds:
I think the Regarding the case where there is no
We should thus return the empty string (opposed to The code would be something like this (not tested):
|
Difficult decision. In any case, we need a simple and backwards compatible way for users to adapt their code if we decide to break it. |
4917676
to
ae2cd26
Compare
Implemented in |
OK, gotta fix the tests... 😄 |
ae2cd26
to
9229e44
Compare
If a browser encounters a select element without any selected option element, it automatically pre-selects the first one. If multiple options are selected, all but the last one get deselected.
9229e44
to
b25b7c9
Compare
Thanks! |
If a browser encounters a select element without any selected option element, it automatically pre-selects the first one. This change reflects that in FormElement.form_values.
Another option would be to reflect it in SelectElement.value (having the same effect on FormElement.form_values) but I guess that would be a rather huge breaking change considering code that expects SelectElement.value to return None if nothing is selected in the markup. On the other hand, it would match what you get when you check the select element's value e.g. in JavaScript.