Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(jqLite): return [] for .val() on <select multiple> with no selection #15104

Merged
merged 4 commits into from
Sep 8, 2016

Conversation

mgol
Copy link
Member

@mgol mgol commented Sep 7, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature (an API change).

What is the current behavior? (You can also link to an open issue here)
The .val() getter on <select multiple>...</select> returns null if no options are selected.

What is the new behavior (if this is a feature change)?
The .val() getter on <select multiple>...</select> returns an empty array if no options are selected.

Does this PR introduce a breaking change?
Yes.

Please check if the PR fulfills these requirements

Other information:

Fixes #14370

@mgol mgol added this to the 1.6.x milestone Sep 7, 2016
@mgol mgol self-assigned this Sep 7, 2016
@mgol mgol changed the title Jqlite feat(jqLite): return [] for .val() on <select multiple> with no selection Sep 7, 2016
@petebacondarwin
Copy link
Contributor

LGTM - should the refactorings be backported to 1.5.x?

@mgol
Copy link
Member Author

mgol commented Sep 7, 2016

Yes, I plan to backport them.

On Wednesday, 7 September 2016, Pete Bacon Darwin [email protected]
wrote:

LGTM - should the refactorings be backported to 1.5.x?


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#15104 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABrUnoMv-Ghp6Qc7aTNHSqaP05mAD8t7ks5qnr7bgaJpZM4J26Jd
.

Michał Gołębiowski

toEqualOneOf: function(util) {
return {
compare: function(actual) {
var expectedArgs = Array.prototype.slice.call(arguments, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can sliceArgs(arguments, 1) be used here instead (for readability)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kind of weird to use internal Angular functions in matchers. IMO tests shouldn't depend on the code they're testing. Also, all other relevant matchers in this file use this technique so changing it just here would be inconsistent.

@gkalpak
Copy link
Member

gkalpak commented Sep 7, 2016

LGTM2 😃

mgol added 4 commits September 8, 2016 09:55
…tion

Fixes angular#14370

BREAKING CHANGE: For the jqLite element representing a select element in
the multiple variant with no options chosen the .val() getter used to return
null and now returns an empty array.

To migrate the code follow the example below:

Before:

HTML:

    <select multiple>
        <option>value 1</option>
        <option>value 2</option>
    </select>

JavaScript:

    var value = $element.val();
    if (value) {
        /* do something */
    }

After:

HTML:

    <select multiple>
        <option>value 1</option>
        <option>value 2</option>
    </select>

JavaScript:

    var value = $element.val();
    if (value.length > 0) {
        /* do something */
    }
@mgol mgol merged commit d882fde into angular:master Sep 8, 2016
@mgol
Copy link
Member Author

mgol commented Sep 8, 2016

Closed via d882fde (I forgot to update the commit message).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.