From 1823848b5c2ab76cb756b9ede2a5f0dd72822479 Mon Sep 17 00:00:00 2001 From: Seth Falco Date: Wed, 21 May 2025 21:55:06 +0100 Subject: [PATCH] fix(convertColors): use currentColor instead of currentcolor --- docs/04-plugins/convertColors.mdx | 2 +- docs/04-plugins/removeAttrs.mdx | 2 +- plugins/convertColors.js | 8 ++++++-- test/plugins/convertColors.04.svg.txt | 10 +++++----- test/plugins/convertColors.06.svg.txt | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/04-plugins/convertColors.mdx b/docs/04-plugins/convertColors.mdx index f0a0b00f1..3cd2d77b2 100644 --- a/docs/04-plugins/convertColors.mdx +++ b/docs/04-plugins/convertColors.mdx @@ -5,7 +5,7 @@ svgo: defaultPlugin: true parameters: currentColor: - description: If to convert all instances of a color to `currentcolor`. This means to inherit the active foreground color, for example in HTML5 this would be the [`color`](https://developer.mozilla.org/docs/Web/CSS/color) property in CSS. + description: If to convert all instances of a color to `currentColor`. This means to inherit the active foreground color, for example in HTML5 this would be the [`color`](https://developer.mozilla.org/docs/Web/CSS/color) property in CSS. default: false names2hex: description: If to convert color names to the hex equivalent. diff --git a/docs/04-plugins/removeAttrs.mdx b/docs/04-plugins/removeAttrs.mdx index 2ea887052..7bb5fd650 100644 --- a/docs/04-plugins/removeAttrs.mdx +++ b/docs/04-plugins/removeAttrs.mdx @@ -10,7 +10,7 @@ svgo: description: The pattern syntax used by this plugin is `element:attribute:value`, this changes the delimiter from `:` to another string. default: ':' preserveCurrentColor: - description: If to ignore the attribute when it's set to `currentcolor`. + description: If to ignore the attribute when it's set to `currentColor`. default: false --- diff --git a/plugins/convertColors.js b/plugins/convertColors.js index 7c7d8e1cd..cf541595c 100644 --- a/plugins/convertColors.js +++ b/plugins/convertColors.js @@ -107,7 +107,7 @@ export const fn = (_root, params) => { matched = val !== 'none'; } if (matched) { - val = 'currentcolor'; + val = 'currentColor'; } } @@ -136,7 +136,11 @@ export const fn = (_root, params) => { } } - if (convertCase && !includesUrlReference(val)) { + if ( + convertCase && + !includesUrlReference(val) && + val !== 'currentColor' + ) { if (convertCase === 'lower') { val = val.toLowerCase(); } else if (convertCase === 'upper') { diff --git a/test/plugins/convertColors.04.svg.txt b/test/plugins/convertColors.04.svg.txt index 0a9d6c26f..b79ce5e53 100644 --- a/test/plugins/convertColors.04.svg.txt +++ b/test/plugins/convertColors.04.svg.txt @@ -11,12 +11,12 @@ @@@ - - + + - - - + + + diff --git a/test/plugins/convertColors.06.svg.txt b/test/plugins/convertColors.06.svg.txt index 5c5c607de..3a79f8149 100644 --- a/test/plugins/convertColors.06.svg.txt +++ b/test/plugins/convertColors.06.svg.txt @@ -21,7 +21,7 @@ Do not apply currentColor to masks. @@@ - + @@ -33,7 +33,7 @@ Do not apply currentColor to masks. - + @@@