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

domProps has twice the "value" key #6917

Closed
FranckFreiburger opened this issue Oct 25, 2017 · 4 comments
Closed

domProps has twice the "value" key #6917

FranckFreiburger opened this issue Oct 25, 2017 · 4 comments

Comments

@FranckFreiburger
Copy link

FranckFreiburger commented Oct 25, 2017

Version

2.5.2

Reproduction link

https://jsfiddle.net/50wL7mdz/71920/

Steps to reproduce

run the jsfiddle program and look at the textarea content, more precisely the last "domProps"

What is expected?

do not generate same key twice

What is actually happening?

... .domProps:{"value":'foo',"value":(model)} ...


This will rise an error in strict mode.
The JSFiddle example don't rise the error because it not in strict mode.
I have discovered the issue using webpack + babel + test on IE11

@yyx990803
Copy link
Member

v-model expands to a value binding, it doesn't make sense to use it and an explicit value binding side by side.

@FranckFreiburger
Copy link
Author

FranckFreiburger commented Oct 26, 2017

Ok thanks.
Just note that in my example:

 <input
    :type="'radio'"
    v-model="model"
    :value="'foo'"
  >

If I replace dynamic type :type="'radio'" with static type type="radio", everything is ok, is it expected ?

@yyx990803
Copy link
Member

Yes, because v-model expands into different props depending on the type binding.

@FranckFreiburger
Copy link
Author

I understand.
I just tying to create a widget that fits the input data type:

<div id="app">
  <input
    v-for="option in options"
    :type="multiple ? 'checkbox' : 'radio'"
    v-model="model"
    :value="option.value"
  >
</div>
new Vue({
  el: '#app',
  data: {
    //model:[2],
    model:2,
    options: [
    	{ value:'1', text:'foo 1' },
    	{ value:'2', text:'foo 2' },
    	{ value:'3', text:'foo 3' }, // ...
    ],
  },
  computed: {
    multiple() {
    	return Array.isArray(this.model);
    }
  }
})

If I understand, this will never work ? is it possible to be warned in DEV mode about this case ?

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

No branches or pull requests

2 participants