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
<select> bound with array performs incorrectly after splice() #3821
Comments
Just add a selected attribute in your template I update the demo here https://jsfiddle.net/trwp98g9/5/ |
@peteranny Can you clarify what was the expected behavior?
I'm not getting the same result as you provided from here:
So what exactly should it become? The value of 'b' was 1 before click, and became 0 after click. |
@fnlctrl Um, thank you for your testing. I think I've asked the wrong question. My true question is: now that the value of 'b' was 0, why was |
@peteranny It may be a bug because For now, you can try adding |
Tested on 2.0 and it worked as expected: https://jsfiddle.net/dycmgzcm/ |
Closing 1.x issues as 1.x is now end of life and will only receive critical security patches. |
Consider the following code:
In
<select>
, each option value is bound with$index
. If we performsplice()
onoptions
, like,options.splice(0,1)
,$index
does not correctly sync with options.For example, let
options=['a','b']
and the rendered HTML looks like (but not really):After
options.splice(0,1)
, thenoptions=['b']
, but the rendered HTML becomes:The value of 'b' option does not become 1, which should be 0 because of
$index
. This may not be a bug, but this is kind of odd.Below is the live demo of this issue:
https://jsfiddle.net/peteranny/trwp98g9/4/
The text was updated successfully, but these errors were encountered: