-
Notifications
You must be signed in to change notification settings - Fork 16
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
Cannot set property className of #<SVGElement> which has only a getter #52
Comments
Looking at the code, Html.Attribute.class uses: https://github.com/elm/html/blob/1.0.0/src/Html/Attributes.elm#L162
And TypedSvg.Attribute.class uses: https://github.com/elm-community/typed-svg/blob/7.0.0/src/TypedSvg/Core.elm#L58
Both define
So long as TypedSvg is just a set of typed constructors built directly on top of VirtualDom, there isn't really a way to prevent this. TypedSvg would need some kind of intermediate representation to prevent you mixing in Html.Attribute stuff. Its unfortunate this causes a runtime exception. The best way to fix this might be for VirtualDom to do better checking and ignore invalid attributes. This was also mentioned on the Elm discourse recently: https://discourse.elm-lang.org/t/valid-code-with-runtime-exception/8787 Workaround: User |
The distinction between the two different ways of defining the class could also be mentioned in the docs and is something that might be worth adding to this package. |
I was able to cause a bug using
TypedSvg
withHtml.Attributes
.in particular, using
Html.Attributes.class
on aTypedSvg
SVG's shape elements went badly.here's what it looked like:
(additionally, it broke other functionality in my app.)
this code triggered it:
removing the
class
attributes fixed the problem.off the top of my head, I'm not sure what the solution should be for this bug. but I can see that
TypedSvg.Attribute
useselm/virtual-dom
attributes under the hood, which is probably why I'm able to throw incorrect attributes onto my SVGs here. so maybe there's a way to articulate withinTypedSvg.Attribute
which virtual DOM attributes can pass through and which ones need to be re-implemented or restricted in some way.The text was updated successfully, but these errors were encountered: