Skip to content
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

Namespaced attributes are not exported correctly #100

Open
wout opened this issue Mar 10, 2023 · 2 comments
Open

Namespaced attributes are not exported correctly #100

wout opened this issue Mar 10, 2023 · 2 comments

Comments

@wout
Copy link
Member

wout commented Mar 10, 2023

I'm using svgdom for a project, and it's doing an awesome job. So far, it has helped us generate over 4000 SVG files which are then exported to PNG using Inkscape.

We had one issue though. Namespaced (xlink) attributes are rendered without the namespace. I've now fixed this in Crystal on the server side:

  private def fix_svg_xlink_attributes(svg)
    svg.gsub(/ href="#/, %( xlink:href="#))
  end

But it's not an ideal situation.

I'm just calling outerHTML on the generated SVG element. Maybe I'm missing something?

@Fuzzyma
Copy link
Member

Fuzzyma commented Mar 10, 2023

Mh, usually attributes should contain the name space if there were created with such.
Is it only happen with xlink or are other namespaces affected as well?

The namespace part is not the easiest part of the Dom spec to understand tbh so it's very well possible that there is a bug in the implementation :D

@wout
Copy link
Member Author

wout commented Mar 10, 2023

That's the only namespace we use, so I'm not sure if it also affects others. We're not using SVG.js btw, just a micro SVG lib. It's using setAttributeNS on the elements in question. Calling outerHTML in the browser and saving that to a file does work. So something's not right there.

I can give you access to the repo if you want. It's a simple internal Node app with three endpoints each returning an SVG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants