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

Model .number modifier fails to cast selected value of select element. #4018

Closed
gskema opened this issue Oct 23, 2016 · 2 comments · Fixed by #4022
Closed

Model .number modifier fails to cast selected value of select element. #4018

gskema opened this issue Oct 23, 2016 · 2 comments · Fixed by #4022
Assignees
Labels

Comments

@gskema
Copy link

gskema commented Oct 23, 2016

Vue.js version

2.0.3

Reproduction Link

https://jsfiddle.net/e4mxqbfv/1/

Steps to reproduce

Change the selected option an look at the output in <pre> element below.

What is Expected?

Selected number type should be a Number because <select> element is bound to a variable (model) and has .number modifier: <select v-model.number="perpage">.

What is actually happening?

Vue fails to cast the selected value to Number, it remains a String.

Workarounds

Some people have suggested binding the value <option :value="10">10</option>, but that's a workaround, not a fix. It's be great if the modifier worked on <select> too or at least there would be a notice in the documentation.

@gskema gskema changed the title Model number modifier fails to cast selected value in select element. Model number modifier fails to cast selected value of select element. Oct 23, 2016
@gskema gskema changed the title Model number modifier fails to cast selected value of select element. Model .number modifier fails to cast selected value of select element. Oct 23, 2016
@defcc defcc added the 2.0 label Oct 23, 2016
@defcc
Copy link
Member

defcc commented Oct 23, 2016

Thanks @gskema , I am looking into this.

@defcc defcc self-assigned this Oct 23, 2016
@defcc defcc added the bug label Oct 23, 2016
@defcc
Copy link
Member

defcc commented Oct 23, 2016

I'll fix the problem later

yyx990803 pushed a commit that referenced this issue Nov 1, 2016
…#4022)

* support number modifier in select, radio, checkbox

* add test case

* add ASTModifier type to specify modifiers type

* fix typo

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

Successfully merging a pull request may close this issue.

2 participants