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

Comments

Projects
None yet
4 participants
@rhyzx
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Jan 15, 2016

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

@rhyzx

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Member

commented Jan 16, 2016

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

@rhyzx

This comment has been minimized.

Copy link
Contributor Author

commented Jan 16, 2016

What about the modifier name? is .boolean ok?

@yyx990803

This comment has been minimized.

Copy link
Member

commented Jan 16, 2016

Yeah I think so.

@rhyzx

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Member

commented Jan 16, 2016

+1 😺

@posva

This comment has been minimized.

Copy link
Member

commented Jan 16, 2016

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

@rhyzx

This comment has been minimized.

Copy link
Contributor Author

commented Jan 17, 2016

@posva wel ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.