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

fix($compiler): Allow using array value with array v-model in checkboxes, fix #6219 #6220

Merged

Conversation

nickmessing
Copy link
Member

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:
Fix #6219

@@ -93,7 +93,7 @@ function genCheckboxModel (
'if(Array.isArray($$a)){' +
`var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
'$$i=_i($$a,$$v);' +
`if($$el.checked){$$i<0&&(${value}=$$a.concat($$v))}` +
`if($$el.checked){$$i<0&&(${value}=$$a.concat(Array.isArray($$v)?[$$v]:$$v))}` +
Copy link
Member Author

@nickmessing nickmessing Jul 26, 2017

Choose a reason for hiding this comment

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

We could just use [$$v] instead of Array.isArray($$v)?[$$v]:$$v I guess but I find this way more verbose (does it make sense?).

Copy link
Member

Choose a reason for hiding this comment

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

I think using [$$v] is a safer way of doing it. No need for ternary imo
You can add a comment if you want

Copy link
Member Author

Choose a reason for hiding this comment

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

@posva, you're right and it's common enough, doesn't need a comment.

@yyx990803 yyx990803 merged commit d6e6f1d into vuejs:dev Sep 1, 2017
@nickmessing nickmessing deleted the fix/checkbox-array-value-array-model branch September 1, 2017 21:37
FranklinTesla pushed a commit to FranklinTesla/vue that referenced this pull request Sep 5, 2017
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

Successfully merging this pull request may close these issues.

checkbox with array model doesn't work with an array value
3 participants