From f9a6a3714315f06c53ead90b58fa8d9a7229841d Mon Sep 17 00:00:00 2001
From: Marco Beretta <81851188+berry-13@users.noreply.github.com>
Date: Wed, 24 Jun 2026 15:21:23 +0200
Subject: [PATCH] fix: count paint only on rendered shapes and filter hidden
CSS currentColor
---
client/src/utils/__tests__/svg.test.ts | 32 ++++++++++++
client/src/utils/svg.ts | 68 ++++++++++++++++++++++----
2 files changed, 91 insertions(+), 9 deletions(-)
diff --git a/client/src/utils/__tests__/svg.test.ts b/client/src/utils/__tests__/svg.test.ts
index ee902f8713..a86b1acc3a 100644
--- a/client/src/utils/__tests__/svg.test.ts
+++ b/client/src/utils/__tests__/svg.test.ts
@@ -241,6 +241,18 @@ describe('isMonochromeSvg', () => {
expect(isMonochromeSvg(svg)).toBe(true);
});
+ it('ignores a CSS currentColor paint that only targets a hidden element', () => {
+ const svg =
+ '';
+ expect(isMonochromeSvg(svg)).toBe(true);
+ });
+
+ it('still counts a CSS currentColor paint on a visible shape', () => {
+ const svg =
+ '';
+ expect(isMonochromeSvg(svg)).toBe(false);
+ });
+
it('preserves a chromatic fill applied to the root via CSS', () => {
const svg =
'';
@@ -254,6 +266,26 @@ describe('isMonochromeSvg', () => {
});
});
+ describe('paint set on non-rendering containers', () => {
+ it('tints a glyph whose root fill is overridden by every rendered shape', () => {
+ const svg =
+ '';
+ expect(isMonochromeSvg(svg)).toBe(true);
+ });
+
+ it('tints a glyph whose group fill no rendered shape inherits', () => {
+ const svg =
+ '';
+ expect(isMonochromeSvg(svg)).toBe(true);
+ });
+
+ it('still counts a container fill inherited by an unpainted shape', () => {
+ const svg =
+ '';
+ expect(isMonochromeSvg(svg)).toBe(false);
+ });
+ });
+
describe('default fills alongside