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

removeUnusedNS plugin doesn't remove unused namespaces declared on non-svg nodes #844

Open
alexjlockwood opened this issue Nov 20, 2017 · 3 comments

Comments

@alexjlockwood
Copy link
Contributor

alexjlockwood commented Nov 20, 2017

For example:

$ svgo --pretty -o - -s  '<svg 
      xmlns="http://www.w3.org/2000/svg"
      xmlns:firstunused="http://first-unused-namespace.com">
      <path xmlns:secondunused="http://second-unused-namespace.com"
          d="M0 0l100 100" />
  </svg>'

results in:

<svg xmlns="http://www.w3.org/2000/svg">
    <path xmlns:secondunused="http://second-unused-namespace.com" d="M0 0l100 100"/>
</svg>

I would expect that the unused namespace declared on the path element would be removed in this scenario.

@GreLI
Copy link
Member

GreLI commented Nov 20, 2017

The plugin removes only known namespaces like editor-spamming ones.

@alexjlockwood
Copy link
Contributor Author

Still, it doesn't seem like the plugin would currently remove these "known" namespaces if they are declared on non-SVG nodes, right?

The reason I say this is because when I look at the source code, I notice that the namespaces are currently only collected while iterating over the root SVG node.

@piuccio
Copy link

piuccio commented Apr 19, 2019

Just stumbled upon this, somehow I ended up with an SVG that looks like this

<?xml version="1.0"?>
<svg width="160" height="70" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:se="http://svg-edit.googlecode.com" xmlns:xlink="http://www.w3.org/1999/xlink">
 <!-- Created with SVG-edit - https://github.com/SVG-Edit/svgedit-->
 <defs>
  <symbol height="70" id="svg_2" width="140" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">

Notice the xmlns and xmlns:svg on the nested symbol

Would be great if the plugin was able to remove it.

The linked PR seems to be stale, any chance someone could have a look?

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

Successfully merging a pull request may close this issue.

3 participants