diff --git a/plugins/convertColors.js b/plugins/convertColors.js
index aa9c8fa77..6c7fdfd0b 100644
--- a/plugins/convertColors.js
+++ b/plugins/convertColors.js
@@ -73,15 +73,20 @@ export const fn = (_root, params) => {
shortname = true,
} = params;
+ let maskCounter = 0;
+
return {
element: {
enter: (node) => {
+ if (node.name === 'mask') {
+ maskCounter++;
+ }
for (const [name, value] of Object.entries(node.attributes)) {
if (colorsProps.has(name)) {
let val = value;
// convert colors to currentColor
- if (currentColor) {
+ if (currentColor && maskCounter === 0) {
let matched;
if (typeof currentColor === 'string') {
matched = val === currentColor;
@@ -148,6 +153,11 @@ export const fn = (_root, params) => {
}
}
},
+ exit: (node) => {
+ if (node.name === 'mask') {
+ maskCounter--;
+ }
+ },
},
};
};
diff --git a/test/plugins/convertColors.06.svg.txt b/test/plugins/convertColors.06.svg.txt
new file mode 100644
index 000000000..5c5c607de
--- /dev/null
+++ b/test/plugins/convertColors.06.svg.txt
@@ -0,0 +1,41 @@
+Do not apply currentColor to masks.
+
+===
+
+
+
+@@@
+
+
+
+@@@
+
+{ "currentColor": true }