Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set selectedIndex to -1 when no option matches bound select value
Previously, when the bound value of a select element was set to `null` or any other value not matching one of the options, the first option would appear selected. So even if the select element was `required`, users could submit the form and end up sending a different value than what it appeared they were submitting. With this change, if a select element is bound to a value that doesn't match one of its options, then none of the options will appear selected. This helps catch bugs during development when the bound value inadvertently doesn't match an option. It also makes it possible to bind a `required` select element to `null`, and cause the browser to require users to explicitly select an option before the form can be submitted. Resolves #6126. In order for the test to pass, it was necessary to update the jsdom dependency to the latest 15.x release, since v15.2.0 fixed `selectEl.value` when no `<option>` is selected to return the empty string. See https://github.com/jsdom/jsdom/blob/15.2.1/Changelog.md#1520 and jsdom/jsdom@699ed6b.
- Loading branch information