-
Notifications
You must be signed in to change notification settings - Fork 42
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
svg import breaks html #684
Comments
Good point, I also stumbled over this in the past, it is really confusing. Currently i would recommend to use the svg import only locally. Alternatively you could refer to it by full package name or alias. There are some things to consider with the svg/html conflicts. @busti looked into it as well some time ago. |
Unfortunately abstracting over SVG / HTML elements any further is not worth the effort. Solving this on the type-level would need 3 type parameters on I have some ideas about making it work in scala 3, but adoption is slow. When using SVG and HTML tags within the same scope it can also be helpful to redirect some imports like this: |
Would it be possible to print a warning to the console at runtime or is that similar effort? |
I don't think that there is an easy way to detect that during compile time without using a macro or a compiler plugin. Scapegoat has a linting feature for variable shadowing, but I do not know it that works for imports since these often share names. Unfortunately inserting an SVG into an HTML element at runtime is perfectly valid. I found that creating a method or a custom file for each SVG component that I write and importing the svg namespace only locally worked out fine. |
Hi,
as shown in the last commit in the following reproducer repository https://github.com/mohe2015/outwatch-issue-1/blob/master/webapp/src/main/scala/webapp/Main.scala the svg import breaks the html.
If you open that page in chromium based browsers it shows nothing but if you click "edit as html" and e.g. change the text it suddenly appears. If you open the page in firefox it also shows nothing but if you inspect the element it says "edit as svg" which hints that this somehow is interpreted as an svg element.
I think this is highly unexpected behaviour especially when it's not that clearly visible in the code after each other. I think the svg behaviour should only happen within svg elements except if there is a good reason for other behaviour.
Kind regards
Moritz
The text was updated successfully, but these errors were encountered: