diff --git a/plugins/removeUselessStrokeAndFill.js b/plugins/removeUselessStrokeAndFill.js
index 5b055890a..012cf9c81 100644
--- a/plugins/removeUselessStrokeAndFill.js
+++ b/plugins/removeUselessStrokeAndFill.js
@@ -28,18 +28,22 @@ export const fn = (root, params) => {
removeNone = false,
} = params;
- // style and script elements deoptimize this plugin
- let hasStyleOrScript = false;
+ // style, animation, and script elements deoptimize this plugin
+ let deoptimized = false;
visit(root, {
element: {
enter: (node) => {
- if (node.name === 'style' || hasScripts(node)) {
- hasStyleOrScript = true;
+ if (
+ node.name === 'style' ||
+ hasScripts(node) ||
+ elemsGroups.animation.has(node.name)
+ ) {
+ deoptimized = true;
}
},
},
});
- if (hasStyleOrScript) {
+ if (deoptimized) {
return null;
}
diff --git a/test/plugins/removeUselessStrokeAndFill.06.svg.txt b/test/plugins/removeUselessStrokeAndFill.06.svg.txt
new file mode 100644
index 000000000..5e7adcda7
--- /dev/null
+++ b/test/plugins/removeUselessStrokeAndFill.06.svg.txt
@@ -0,0 +1,34 @@
+Issue 1677: don't remove fill from animated elements.
+
+===
+
+
+
+@@@
+
+
+