Skip to content

removeUselessStrokeAndFill fails at animations #1677

@cyberalien

Description

@cyberalien

Describe the bug
A clear and concise description of what the bug is.

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">
    <circle cx="12" cy="12" r="8" fill="currentColor" fill-opacity="0">
        <animate attributeName="fill-opacity" values="0;1" begin="1.2s" dur="0.4s" fill="freeze" />
    </circle>
</svg>`,
		{ plugins: ['removeUselessStrokeAndFill'] }
	)
);

Result:

{
  data: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="none"><animate attributeName="fill-opacity" values="0;1" begin="1.2s" dur="0.4s" fill="freeze"/></circle></svg>',
  info: { width: '24', height: '24' }
}

Notice that fill="currentColor" was changed to fill="none".

Expected behavior
Expected not to change fill because fill-opacity is being animated, so actual value of fill-opacity is not 0.

Desktop (please complete the following information):

  • SVGO Version 2.8.0
  • NodeJs Version 16.14.2
  • OS: macOS 12.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions