markup.ml
markup.ml copied to clipboard
Adjust SVG attributes irrespective of their namespace
Hi!
I am using tyxml and ran into the same issue as https://github.com/ocsigen/tyxml/issues/307, but with the attribute viewBox instead. It only occurs with the ppx so I looked into the html_parser as suggested by @mooreryan in the issue (thanks!).
As far as I can tell, this is what happens:
- Html parser sees
<svg>tag and parses it in the SVG namespace here. - This is supposed to trigger the case corrections for attributes in here.
- The correction function itself only corrects attributes that have the SVG namespace prefix here.
I don't know enough about namespaces and the use cases of this library, but from my POV there are two fixes:
- Add the SVG namespace to all attributes behind the scenes, similar to how the SVG namespace is added to the
svgelement implicitly. - Ignore the namespace in
adjust_svg_attributesbecause the decision to adjust attribute names is already made by the caller.
This PR adds a test with my own use case and passes it by choosing option 2. I also built and tested the tyxml repository against this PR which works fine.