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

Plugins reusePaths and removeXMLNS conflict as of version 2.8.0 #1617

Closed
remcohaszing opened this issue Nov 11, 2021 · 3 comments
Closed

Plugins reusePaths and removeXMLNS conflict as of version 2.8.0 #1617

remcohaszing opened this issue Nov 11, 2021 · 3 comments
Labels

Comments

@remcohaszing
Copy link

Describe the bug

As of version 2.8.0, combining both removeXMLNS and reusePaths yields an error.

To Reproduce

Steps to reproduce the behavior:

Given the following script:

const { optimize } = require('svgo');

const options = {
  js2svg: {
    indent: 2,
    pretty: true,
  },
  multipass: true,
  plugins: [
    { name: 'reusePaths', active: true },
    { name: 'removeXMLNS', active: true },
  ],
}

const svg = `
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 0 0">
  <defs>
    <path d=""></path>
    <path d=""></path>
  </defs>
</svg>
`

const result = optimize(svg, options);

console.dir(result);
  1. Install svgo 2.7.0
  2. Run the script
  3. Notice a result is logged
  4. Install svgo 2.8.0
  5. Run the script
  6. Notice an error is logged

The following will make the error go away:

  • Set multipass: false
  • Disable the reusePaths plugin
  • Disable the removeXMLNS plugin

Expected behavior

Used namespaces aren’t removed by removeXMLNS, so the plugins can work together.

Screenshots

N/A

Desktop (please complete the following information):

  • SVGO Version: 2.8.0
  • NodeJs Version 16.13.0
  • OS: Pop!_OS 21.04

Additional context

The error was introduced in version 2.8.0.

@TrySound
Copy link
Member

Yeah, parser indeed doesn't understand unbound namespace. This was unexpecteed. But anyway, at the moment only convertTransform may produce different result with multipass. And we gonna make it more deterministic. So I recommend to disable multipass mode. It will be removed in v3.

remcohaszing added a commit to remcohaszing/remark-mermaidjs that referenced this issue Nov 16, 2021
The SVGO option `multipass` is disabled because of
svg/svgo#1617.
@cyberalien
Copy link
Contributor

It will be removed in v3.

Still bugged in 3.0.2

@SethFalco
Copy link
Member

SethFalco commented Nov 18, 2023

Hey, and thanks for reporting the issue!

This has been resolved and will be released in SVGO v3.0.4.

  • removeXMLNS will no longer remove the XLink namespace at all.
  • A new plugin, removeXlink can be used to migrate from the XLink namespace to the SVG 2 equivalent when only SVG 2 or inline HTML compatibility is required. (disabled by default)

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

No branches or pull requests

4 participants