-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Only use create_element_ns if needed #3970
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
Conversation
|
Visit the preview URL for this PR (updated for commit 74b1488): https://yew-rs-api--pr3970-fix-static-svg-mefzjmn7.web.app (expires Thu, 08 Jan 2026 19:11:08 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Benchmark - coreYew MasterPull Request |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
|
thanks for reporting, will look into it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed report. Tested on both browsers and was able to reproduce the bug and confirm the fix.
Description
Summary
Using
create_element_nsinBRaw::create_elementswithout a namespace and setting the inner HTML to the source for an SVG (with a properxmlnsattribute) fails in Chrome because the inner elements are fixed with no namespace. To address this issue, I've updatedBRaw::create_elementsto usecreate_elementwhen the parent namespace isNone.The Story
When I upgraded to yew 0.22, I found that SVGs were not rendering properly. The way I was including an SVG was as follows (simplified to remove the ability to choose the icon).
This renders properly in Firefox with both the old and new version, but does not render properly in Chrome with yew 0.22.
I was able to reproduce the issue that arose due to this commit. If you open a blank page in Chrome and run these commands at the console, an icon is added to the page.
If you change the first line to
createElementNSwithnullfor the namespace, an icon does not appear, but you can still see it if you inspect the page.Here is an image showing the
<svg>in the inspect pane that is not rendered.If you inspect the namespace of the two SVG elements, you can see that Chrome has left the namespace blank on the second one.
Checklist
I can't figure out a way to test this fix as it seems the tests are run in Firefox anyway.