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

Boolean attributes #2169

Closed
rhyzx opened this issue Jan 15, 2016 · 9 comments
Closed

Boolean attributes #2169

rhyzx opened this issue Jan 15, 2016 · 9 comments

Comments

@rhyzx
Copy link

rhyzx commented Jan 15, 2016

According to the HTML5 spec:

The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.

So, in order to make my code spec compatible, i'd do in this way in vue: <input :checked="checked ? '' : false">, do you think it is necessary to directly support boolean attributes in vue? @yyx990803

Solutions I can think of are these:

  • By another directive: v-add:selected="true" (not recommand)
  • By modifier: v-bind:selected.boolean="true" (recommand)
  • Auto: v-bind:selected="true", we need to mantain a boolean attribute list(see), and this may have compatibility problems.

Again, if you think it is necessary, let me handle this! :trollface:

@yyx990803
Copy link
Member

What's the problem with <input :checked="checked">? Vue removes the attribute if checked is falsy.

@rhyzx
Copy link
Author

rhyzx commented Jan 16, 2016

Well, <input checked="true"> and <input checked="1"> are invalid in HTML(although they can work in most browsers), only <input checked> and <input checked="checked"> are valid.

@yyx990803
Copy link
Member

Ok, I guess the modifier is the best way to go. Should be easy too. PR welcome :)

@rhyzx
Copy link
Author

rhyzx commented Jan 16, 2016

What about the modifier name? is .boolean ok?

@yyx990803
Copy link
Member

Yeah I think so.

@rhyzx
Copy link
Author

rhyzx commented Jan 16, 2016

By the way, could you email me your email address? it would be more convenient talk in my native language. XD

@kazupon
Copy link
Member

kazupon commented Jan 16, 2016

+1 😺

@posva
Copy link
Member

posva commented Jan 16, 2016

@rhyzx Thank you for posting your issues in English! 😄

@rhyzx
Copy link
Author

rhyzx commented Jan 17, 2016

@posva wel ;)

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

4 participants