-
Notifications
You must be signed in to change notification settings - Fork 197
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 type error when using CSS in an SVG element's attributes #543
Comments
I got the exact same error when updating a side project to latest elm-css. Everything compiles fine but viewing in the browser I get the error mentioned. My use case was - import Svg.Styled.Attributes exposing (css)
svg
[ viewBox "0 0 200 400"
, css [ Css.width (Css.px 140) ]
]
[] I can understand why this looks dodgy as svg attributes like width tend to just be string values, not px. It was however working fine with versions <17. My fix was to use the following - svg
[ viewBox "0 0 200 400"
, SvgAttribs.width (Css.num 140).value
]
[] It worries me that the compiler doesn't protect against this. Will definitely need to go through projects and ensure everything still works. |
This seems far more serious than I thought actually. All of the css I have added to svg elements just blows up the browser when they are rendered. I have had to work around this by adding styles to wrapping elements, including animations. |
I have a working fork here https://github.com/Confidenceman02/elm-css. All tests passing but not totally sure what the ramifications are when using |
After some talks with @robinheghan I tried out using |
Fixed in 17.0.3! |
The following code compiles but throws
Uncaught TypeError: Cannot set property className of #<SVGElement> which has only a getter
in Chrome (and a similar error in Firefox):Ellie: https://ellie-app.com/fCySBLMNKcWa1
There is no error when importing the
css
function fromSvg.Styled.Attributes
.The text was updated successfully, but these errors were encountered: