Skip to content
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

Attr: selectMultipleWithNoValue.val() now returns [] instead of null #828

Closed
timmywil opened this issue Nov 4, 2015 · 7 comments
Closed
Milestone

Comments

@timmywil
Copy link
Member

timmywil commented Nov 4, 2015

From jquery/jquery#2562

We have this line...

In the case of select elements, it returns null when no option is selected and an array containing the value of each selected option when there is at least one and it is possible to select more because the multiple attribute is present.

which could say something like this instead...

When called on select elements that have no option selected, the .val() method returns null, or an empty array if the multiple attribute is present. If at least one option is selected, either the value or an array of values will be returned.

Also, one of the examples will need editing.

Where we have...

var multipleValues = $( "#multiple" ).val() || [];

we can shorten it to...

var multipleValues = $( "#multiple" ).val();
@dmethvin
Copy link
Member

dmethvin commented Nov 5, 2015

Although you'd need to keep the old code if you're using an older version of jQuery, so we'll probably need a version note here?

@timmywil
Copy link
Member Author

timmywil commented Nov 5, 2015

True. I'm not sure how to incorporate the version differences in a concise manner. Maybe we need @kswedberg's English powers.

@AurelioDeRosa
Copy link
Member

@kswedberg Can you please take a look at this issue?

@kswedberg
Copy link
Member

Sure. Which version(s) introduced the change in return value?

@mgol
Copy link
Member

mgol commented Jul 13, 2016

Sure. Which version(s) introduced the change in return value?

Version 3.0.0.

@kswedberg
Copy link
Member

ah, ok. I'll put something together later today.

@kswedberg
Copy link
Member

errrr. tomorrow. sorry.

kswedberg added a commit to kswedberg/api.jquery.com that referenced this issue Jul 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants