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

v-bind=$attrs overrides the input type attribute in 2.5.14 and above #7811

Closed
linnea opened this issue Mar 12, 2018 · 1 comment
Closed

v-bind=$attrs overrides the input type attribute in 2.5.14 and above #7811

linnea opened this issue Mar 12, 2018 · 1 comment

Comments

@linnea
Copy link

linnea commented Mar 12, 2018

Version

2.5.14

Reproduction link

https://jsfiddle.net/linnea/onw3Lfm4/2/

Steps to reproduce

Create a custom component with an input wrapped in a div and:

  1. inherit attributes
    v-bind="$attrs"
  2. Set the type attribute on the input
    type="checkbox"
  3. Have a v-model on that input.

What is expected?

The inner input still receives type="checkbox"

What is actually happening?

No type attribute is inherited


We have a custom checkbox component that provides label styling etc, and used to be able to declare the input type as well as inherit attributes from the component. Other attributes that are set on the inner input are passed correctly (ie disabled, :true-value, etc), but not the type attribute, unless you bind it. This was working prior to v2.5.14.

A temporary fix we've implemented is changing type="checkbox" to :type="'checkbox'", or setting v-bind="$attrs" to a computed property that returns an object with Object.assign({ type: 'checkbox'}, this.$attrs);

Removing the v-model from the input also fixes it, but we use it to handle multiple checkboxes, bound to the same array

Here's the same fiddle above, working in 2.5.13
https://jsfiddle.net/linnea/onw3Lfm4/4/

@fundon
Copy link

fundon commented Mar 13, 2018

Same issue. The type="checkbox" will be you losed in 2.5.15.

privatenumber pushed a commit to privatenumber/vue that referenced this issue Mar 13, 2018
This was referenced Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants