-
Notifications
You must be signed in to change notification settings - Fork 21
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 elements are not rendered with Tyxml_lwd #20
Comments
Thanks for trying :). Please note that this is an alpha release, so things are moving a bit and it is not surprising to find bugs :P. |
Of course, no pressure! I've been trying multiple alternatives, and I'm pleasantly surprised with Lwd, so I wanted to give it a shot, but I'm completely aware that it's a brand new library 🙂
Once you've built the repo, you can open
|
I see. XML namespaces are not managed properly. I will see what we can do (I am not sure how this should be solved). |
I have a fix. It is made of two steps:
diff --git a/lib/app.ml b/lib/app.ml
index 06994d8..b3f928e 100644
--- a/lib/app.ml
+++ b/lib/app.ml
@@ -18,6 +18,7 @@ module El = struct
[ Tyxml_lwd.Svg.path
~a:
[ Tyxml_lwd.Svg.a_d (Lwd.pure "M6 18L18 6M6 6l12 12")
+ ; a_svg_custom "xmlns" "http://www.w3.org/2000/svg"
; a_svg_custom "stroke-linecap" "round"
; a_svg_custom "stroke-linejoin" "round"
; a_svg_custom "stroke-width" "2" This makes me think that the issue goes a bit deeper and should be handled at Tyxml level. I am curious what @Drup thinks about that. |
Hmmm, this is delicate. I guess your issue is that Could you try to instantiate the first tree with an initial value ? |
Well, right now I suppose that xmlns is not reactive, but that's not even a real issue, I could make it reactive if it proved important. The real issue, if I am not mistaken, is that |
Hmm, right, we had an issue like that previously too. IIRC, the "right" way is to provide a different |
I see, I completely missed that. That's a good solution, I will implement it, thanks. |
You have a point though, this could be considered a workaround and maybe we should provide better support for varied namespaces in tyxml directly to avoid it. Could you open a ticket on tyxml to propose it ? I think I'll have lot's of changes in the functor API to do for the next version ... |
Done: ocsigen/tyxml#277 |
The fix live in branch tyxml-svg-xmlns |
Thanks a lot for the swift answer and fix @let-def 🎉 I can confirm this fixes the issue in the repro project! |
Hi,
First off, thanks a lot for your work on Lwd! I started porting a JS app to it yesterday and I'm really impressed by the elegance of the API!
I've encountered an issue with the rendering of SVG elements.
While inspecting the generated HTML, the code looks good, but the SVG is not displayed.
I've pushed a small repro here: https://github.com/tmattio/lwd-svg-repro/blob/main/lib/app.ml.
Let me know if there's anything I can do to help debug that 🙂
The text was updated successfully, but these errors were encountered: