Closed Steve-OH closed 6 years ago
@Steve-OH have you tried using HA.classList
instead of HA.class
?
Here is my generic implementation for showing fa icons:
fa : String -> Element style variation msg
fa faClasses =
Element.html <|
Html.i
[ Html.Attributes.classList <|
List.map (\s -> ( s, True )) <|
String.split " " faClasses
]
[]
and use it by:
fa "far fa-check-square"
@aaronkor
Thanks for the idea; I'll give it a try when I get a chance.
I just discovered the other day that this issue is present in plain ol' Elm as well, so it's not specific to style-elements. Therefore, I'm going to close this one and open one on Elm.
The big picture of what I'm trying to do
I'm trying to use Font Awesome icons in the "new and improved" SVG+JS mode, rather than the old-fashioned CSS mode.
What I did
I could not get the code to work from within Ellie, so here it is:
(Main.elm)
(index.html)
To see the problem, click the button.
What I Expected To Happen
When the button is clicked, the displayed icon should switch between "checked" and "unchecked" forms.
What Actually Happened
Style elements raises an Uncaught TypeError, because it is apparently trying to set the
className
property on an SVG element, which doesn't have a settableclassName
property.The workaround is to go back to old-fashioned CSS mode (see the commented-out line in the HTML), which works fine.
Versions