envjs / env-js

A pure-JavaScript browser environment.
http://www.envjs.com/
87 stars 19 forks source link

Select first option by default #21

Open orslumen opened 13 years ago

orslumen commented 13 years ago

When selectedIndex is requested for the first time, I think it is best to select the first item in the dropdown if nothing was selected and an option is available.

I did not verify that this is according to specs, but at least FF, IE, Safari and Chrome will never return null in case an option is available.

One way to fix this can be found in https://github.com/orslumen/env-js/commit/18d271d71c7f3e6646de8b282d6509bcf40edf9d

But it is probably more correct to select the first option once the HTML is parsed and no options have been marked as selected yet.