-
Notifications
You must be signed in to change notification settings - Fork 20
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 when passing class
attribute from Html package.
#3
Comments
Happened to me as well. |
I had the same problem. @evancz Why -- From Html.Attributes
-- className property can't be used for svg nodes
class value =
VirtualDom.property "className" (Json.string value)
-- From Svg.Attributes
class value =
VirtualDom.attribute "class" value |
SVG does not have JS properties. You can not use properties for anything. I am just curious why people are mixing and matching between these libraries. |
In my case I wasn't intentionally mixing them so once I figured out what went wrong it was easy to fix. Still, it would have been nice if the compiler would have warned me for my stupidity. |
I pretty often use inline SVGs in my HTML and I can add <div class="house">
<svg class="dog">
<path d="" />
</svg>
</div> So when I first time tried Elm, my intuition failed: div [ class "house" ]
[ svg [ class "dog", svgContent "<path d='' />" ] []
]
svgContent content =
property "innerHTML" (Json.Encode.string content) The compiler didn't tell me anything about it. So I got BTW, if |
I ran into this problem because I was using inline SVGs. Easy mistake to make any time you're using inline SVGs. Took some digging to realize what I was doing wrong. |
I am using inline SVGs a lot a also. I am really don't like this runtime exception since only because of this I am checking every page of my Elm project for this issue (and there still possible runtime issues when state changes for example). The most bad thing is that elm compiler allows to pass |
I had same issue. It would be good if it could be caught by compiler, to help enforce "no runtime exceptions". I think the issue is that both |
I just ran into this exact issue today, didn't take long to figure out but still confused because I got a runtime error instead of a compiler error. |
According to the source,
My use is embedding SVG in HTML too. I mistakenly added To fix it I added a wrapper HTML element ( |
I've just ran into the same issue. Accidentally used Yes, it caused a runtime error which was surprising and somewhat disappointing. People are running into this, see the referenced tickets. I also arrived here from such a ticket. I would suggest going ahead with a breaking change to ensure that the type system can still protect us from runtime errors. |
Just wanted to leave here that the same thing happened to me, took me a while to figure out that I had my imports messed up. I feel like since these types are not compatible, the code shouldn't have compiled (or maybe give a warning). It's a bit sad to see that people have had this issue for 3,5 years now. |
Svg nodes don't have props and when trying to set e.g. class using Html.Attributes.class on an svg, a run time error occurs. elm/svg#3
Svg nodes don't have props and when trying to set e.g. class using Html.Attributes.class on an svg, a run time error occurs. elm/svg#3
Svg nodes don't have props and when trying to set e.g. class using Html.Attributes.class on an svg, a run time error occurs. elm/svg#3
Hello from 2020 (what a great year!), I've just spent over an hour wondering why my page fails unexpectedly (and actually goes into infinite loop of |
Greetings from 2022 👋 This bit us as well. Interestingly, this did not cause a fatal runtime error during the development build with the |
I'm not even using Elm anymore. I guess the ecosystem has just stalled due to the Elm 0.19 release fiasco. These issues may never be fixed. |
When attempting to add a class name to an SVG element using
class
from theelm-lang/html
package the compiler doesn't complain. When running the compiled program an error is thrown:It's a stupid mistake, but still, when working with some SVG content nested in an HTML view it's not unlikely to happen.
Below is a sample program that produces the error.
The text was updated successfully, but these errors were encountered: