Open Carlsson87 opened 5 years ago
Caused by https://github.com/elm/virtual-dom/commit/d32f9b4a2f6ceb1d30097818e39b33d3435bafe0
Probably fix would be to also check if attribute key is not empty, since that is not allowed.
Here is @Carlsson87's sscce:
module Main exposing (main)
import Html
import Html.Attributes
main =
Html.div [ Html.Attributes.attribute "" "" ] []
To be extra specific. The problem seems to occur when the key is an empty string. The value being an empty string does not cause any problems for me.
Why are you doing this?
When I conditionally want to set an attribute on an element. I use the same approach with Html.text ""
when I want to conditionally render some elements.
showButton : Maybe msg -> Html msg
showButton clickMsg =
Html.button
[ case clickMsg of
Just msg ->
Html.Events.onClick msg
Nothing ->
Html.Attributes.attribute "" ""
]
[ Html.text "Click here"
]
I'd love to know if there is a better way.
We use a similar pattern for conditional attributes, we have it defined as
none : Attribute msg
none =
Html.Attributes.property "" Json.Encode.null
Which seems to be valid still https://ellie-app.com/3ks2h7XJWnTa1
~@norpan how is d32f9b4 causing this bug?~ ah ok. I understand now. The bug was present before d32f9b4 for all cases Html.Attributes.attribute "" val
except for val = ""
. Now using an empty string also triggers the bug.
I just upgraded to version
1.0.1
and ran in to problems when usingHtml.attribute "" ""
. It didn't use to cause an exception, and now it does. Let me know if you need more info.SSCCE: https://ellie-app.com/3kjwsTXvQNTa1