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

Attribute doesn't update if binded to a property called selected #4233

Closed
hay opened this issue Nov 17, 2016 · 3 comments
Closed

Attribute doesn't update if binded to a property called selected #4233

hay opened this issue Nov 17, 2016 · 3 comments

Comments

@hay
Copy link

hay commented Nov 17, 2016

If you have an element that is binded to an attribute called selected it won't update in the DOM. For example:

<p v-bind:selected="selected">selected is {{selected}}</p>
<button v-on:click="selected = !selected">toggle</button>

Note that the {{selected}} template works fine, and the variable updates as well. It's just the attribute that doesn't update.

Here's a codepen that reproduces the problem: http://codepen.io/hay/pen/mOOrWK

Problem occurs in Vue 2.0.7. This example works fine in 1.0.28.

@yyx990803
Copy link
Member

yyx990803 commented Nov 17, 2016

Selected is bound as a property instead of an attribute. <p> tags don't have selected attribute, why would you want to bind that? If you are doing this for styling purposes, you should be using a class instead.

@hay
Copy link
Author

hay commented Nov 17, 2016

This is indeed for styling purposes. But why should you be using a class? Attributes can be styled in CSS, and sometimes they're more useful than classes.

@hay
Copy link
Author

hay commented Nov 23, 2016

Just checked and the patch in the 2.0.8 release fixed this. Thanks so much!

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