From ef93643a16d967d2b48761c95d793e870a916768 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:43:27 +0200 Subject: [PATCH] fix: only count CSS paints that match rendered elements --- client/src/utils/__tests__/svg.test.ts | 18 +++++++++++ client/src/utils/svg.ts | 44 +++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/client/src/utils/__tests__/svg.test.ts b/client/src/utils/__tests__/svg.test.ts index 0eb83997bc..29f369599b 100644 --- a/client/src/utils/__tests__/svg.test.ts +++ b/client/src/utils/__tests__/svg.test.ts @@ -222,6 +222,24 @@ describe('isMonochromeSvg', () => { ''; expect(isMonochromeSvg(svg)).toBe(false); }); + + it('ignores an unused CSS paint rule that matches no element', () => { + const svg = + ''; + expect(isMonochromeSvg(svg)).toBe(true); + }); + + it('ignores a CSS paint that only targets a hidden element', () => { + const svg = + ''; + expect(isMonochromeSvg(svg)).toBe(true); + }); + + it('preserves a chromatic fill applied to the root via CSS', () => { + const svg = + ''; + expect(isMonochromeSvg(svg)).toBe(false); + }); }); describe('default fills alongside