-
Notifications
You must be signed in to change notification settings - Fork 99
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
Runtime error: passing empty string to Html.Attributes.attribute #46
Comments
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
What should happen instead? Is it worth it to add a check on every |
I'd say the same thing here as what I said over there. 😄 |
Agree - https://github.com/elm-lang/html/issues/47#issuecomment-229562502 fits in well with what I'd expect- given that it can fail |
As commented in #47, |
I think the same resolution from #47 makes sense here as well, so I am going to close. I am not certain this is the right thing, but I don't think we have a workable alternative in either case at this point in time. |
Hi!! Me again, but now in 2020. I just ran into this same issue, and was shocked to find myself from 4 years ago! Hi me of the past!! So here's some information for myself in the future, or for anyone else who lands here: This time (and I assume last time), I hit this because I was trying to conditionally add an attribute to an element, like: Html.div
[ if importantThing then
Html.Event.onClick GoWild
else
Html.Attribute.attribute "" ""
]
[] Seems like people are talkin' about doing stuff like this all over! It turns out though, that a nice way to add an attribute that has no effect on the DOM is to add a blank class. attributeIf : Bool -> Html.Attribute msg -> Html.Attribute msg
attributeIf condition attr =
if condition then
attr
else
Html.Attributes.class ""
...
Html.div
[ attributeIf importantThing (Html.Event.onClick GoWild) ]
[] Anyway, see you again in 4 years future Aaron! |
This comment totally made my day 😂 Miss ya, @strickinato! |
Gives:
Using:
The text was updated successfully, but these errors were encountered: