-
Notifications
You must be signed in to change notification settings - Fork 11
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
support boolean values for boolean attributes #20
Comments
I guess we could add it here? |
Thanks for this issue! I think adding a check for literal @SimonDanisch I'm wondering whether it might make sense to do this uniformly for all tags, rather than HTML's boolean attributes, since it might be confusing if |
Hm, so my idea was, to not leaky this weird behavior into the official API... So I'd say, |
Hm. Here's another thought:
Using this is more verbose and requires the user to know that an attribute is valueless, but it has the benefit of being an explicit and consistent behavior that is orthogonal from the rest of the system. Maybe there's a more concise way to do something like this? |
hm... So I think I kind of consider the html behavior to be a bug :D That's of course also because I haven't really used HTML before using Hyperscript^^ But I would like to push this behavior as far away from the user as possible. Of course this is somewhat dangerous, since that will confuse any user that tries to dig deeper... Or users that have worked a lot with html before ;) |
It's true that this is overlapping but distinct from the issue of deciding whether to put some attribute programmatically, as that can be done with the keyword argument splatting trick proposed above. Thinking more about it, I feel that the issue is more about having a consistent syntax to initialize and update an element, so that it becomes feasible to make a nice library to create dynamic pages based on Hyperscript. In javascript hyperscript (for example mithril) they try to conflate HTML attributes with DOM properties and stringify I would limit this behavior to boolean attributes, as in other attributes it would be surprising (with |
It sounds like using boolean values the same way Mithril does ( @SimonDanisch I think you've correctly identified the place to change this — would you mind making a pull request for special-casing |
Even though the correct HTML5 thing to do is to use valueless boolean attributes or to not add them at all (i.e.
<input type=checkbox checked />
versus<input type=checkbox />
), this becomes a bit awkward when generating them programmatically. In particular, if one wants to add observables to Hyperscript to add interactivity (see SimonDanisch/Bonito.jl#35 for instance), things become a bit awkward.From what I understand, HTML5 actually disallows using
"true"
or"false"
as values for boolean attributes (see here). Could it be possible to support passingchecked = false
to mean that the attribute is actually not set, andchecked = true
to set it?I confess I'm not sure what the attribute should be set to with
checked = true
, but I imagine anything that conforms to HTML5 would be fine (empty string, or name of the attribute, or maybe even valueless).The text was updated successfully, but these errors were encountered: