Skip to content

Different initial selected value in <select> #1008

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

Closed
mbdavid opened this issue Jul 4, 2015 · 1 comment
Closed

Different initial selected value in <select> #1008

mbdavid opened this issue Jul 4, 2015 · 1 comment

Comments

@mbdavid
Copy link

mbdavid commented Jul 4, 2015

Hi, first of all, thanks for this fantastic work.

I note that <select> has a different behavior when using template from DOM element than template string options on Vue initialization.

When use template from DOM element, Vue render select with no value selected (v-model = null).

When using template from a string options, Vue render select with first value selected (v-model = null too).

screenshot-jsfiddle net 2015-07-04 13-01-59

http://jsfiddle.net/8gv321no/

@yyx990803
Copy link
Member

This is caused by some browsers' default behavior that whenever a <select> element is appended to a new parent, and its selectedIndex is -1, the browser resets it to 0. It seems Firefox is the only browser that persists the -1 value properly.

Ideally all browsers should persist the value, but I guess I can't change that so we can only add more ugly patches to Vue :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants