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

removeOffCanvasPaths removes wrong paths #1646

Open
cyberalien opened this issue Feb 4, 2022 · 1 comment
Open

removeOffCanvasPaths removes wrong paths #1646

cyberalien opened this issue Feb 4, 2022 · 1 comment
Labels

Comments

@cyberalien
Copy link
Contributor

Describe the bug
Plugin removeOffCanvasPaths removes paths that are on canvas

To Reproduce
Steps to reproduce the behavior:

const { optimize } = require('svgo');
console.log(
	optimize(
		'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2" d="m12 12 7 7m-7-7L5 5m7 7-7 7m7-7 7-7"/></svg>',
		{ plugins: ['removeOffCanvasPaths'] }
	)
);

Result:

{
  data: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"/>',
  info: { width: '24', height: '24' }
}

Expected behavior
Expected path to not be removed. Path is within canvas.

Desktop (please complete the following information):

  • SVGO Version: 2.8.0
  • NodeJs Version: 16.3.2
  • OS: macOS 12.2
@cyberalien cyberalien added the bug label Feb 4, 2022
@just-boris
Copy link

Another, more simple path to reproduce the same issue:

const Svgo = require('svgo');

const { data } = Svgo.optimize(
  `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
    <path d="m10 5-5 5" stroke="#000"></path>
</svg>`,
  {
    plugins: [`removeOffCanvasPaths`],
  }
);
console.log(data);

As far as I could investigate, it fails this intersection check:

if (intersects(viewBoxPathData, pathData) === false) {

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

2 participants