Closed drue closed 2 months ago
/bounty $150
cc @jgoday if you want to claim the bounty.
/attempt #2963
with your implementation plan/claim #2963
in the PR body to claim the bountyThank you for contributing to zio/zio-http!
Add a bounty • Share on socials
Attempt | Started (GMT+0) | Solution |
---|---|---|
🟢 @jgoday | Jul 30, 2024, 7:35:58 PM | #2973 |
/attempt #2963
Added PartialBooleanAttribute, so we can use boolean attributes without specifying a value (optionally).
input(typeAttr := "text", requiredAttr)
input(typeAttr := "text", requiredAttr := false)
💡 @jgoday submitted a pull request that claims the bounty. You can visit your bounty board to reward.
@jgoday: You've been awarded a $150 bounty by ZIO! 👉 Complete your Algora onboarding to collect the bounty.
Describe the bug Some HTML attributes, e.g.
required
on inputs, are boolean and do not have a value and should be rendered without an equals sign or value like this:<input name="email" required>
see: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required
In Zio HTTP Templates, however, the
required
attribute is the same as all of the other attributes and takes a string value so it always emits an equals and quotes:<input name="email" required="">
which doesn't work in the browser I tried.There are probably other HTML attributes like this and I know some popular front end libs/frameworks rely on these types of boolean attributes.
In Scalatags an empty string will render the attribute without equals or the value so maybe thats how you want to fix this, it certainly the easiest way to do so.
To Reproduce render a template like
input(nameAttr:="email", requiredAttr:="")
Expected behaviour output
<input name="email" required>