Affecting <select> value is now properly updated when non-existent option is programmatically selected

Published: | Categories: DOM

Description

Previously, using JavaScript to change the value property of a <select> element to a value that matched no <option> did not update the selection accordingly, when the <select> element was displayed as a combobox.

Firefox 46 has fixed this bug as per the HTML spec so that any <option> will be unselected in such cases. That means the selectedIndex, selectedOptions and value properties of the <select> element will become -1, an empty HTMLCollection and an empty string respectively.

While the new behaviour should match other browsers, certain sites with Firefox-specific code could be broken with this change.

References