Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Formalize two-way binding with selects. #2027
Using the new two-way binding syntax
However, this makes it difficult to get the nice behavior of showing an empty select when the scope is
This is still possible, but tricky. I'd like a way to make it easier.
I don't think this is fixable. A select field like
<select id="test"> <option>One</option> </select>
When set like this:
var element = document.getElementById('test'); element.value = '';
Will always show an empty select in Chrome/Safari etc. and the first item in Firefox.
If you set the
It seems that all browsers report the value as the first option in the list by default, and then an empty string when the selected index is set to -1.
This is a special case because FF forces it to be.
Ideally, we wouldn't do special casing here. I wonder if it's possible to tell if the value was actually set, or just defaulted to the first item.
Sent from my iPhone
referenced this issue
Nov 2, 2015
changed the title from
Firefox showing first option as selected when there is no value.
Formalize two-way binding with selects.
Nov 2, 2015
Working on this, I'm not sure that the case where a key in a parent scope is undefined should be our concern.
e.g. current behavior (consistent across browsers)
What isn't consistent is what happens when the key's value doesn't match one of the select's options:
This passes in Chrome, but fails in Firefox (selectedIndex === 0).