mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 14:57:42 +00:00
fix: count default-filled polylines when detecting tintable SVGs
This commit is contained in:
parent
bc0fbed488
commit
0073ac106d
2 changed files with 16 additions and 2 deletions
|
|
@ -100,6 +100,17 @@ describe('isMonochromeSvg', () => {
|
|||
expect(isMonochromeSvg(svg)).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects an explicit badge alongside a default-black polyline glyph', () => {
|
||||
const svg =
|
||||
'<svg viewBox="0 0 24 24"><rect x="0" y="0" width="8" height="8" fill="#fff" /><polyline points="6,6 18,6 18,18 6,18" /></svg>';
|
||||
expect(isMonochromeSvg(svg)).toBe(false);
|
||||
});
|
||||
|
||||
it('tints a glyph drawn as a single default-black polyline', () => {
|
||||
const svg = '<svg viewBox="0 0 24 24"><polyline points="6,6 18,6 18,18 6,18" /></svg>';
|
||||
expect(isMonochromeSvg(svg)).toBe(true);
|
||||
});
|
||||
|
||||
it('inherits an ancestor fill instead of assuming the default black', () => {
|
||||
const svg = '<svg viewBox="0 0 24 24"><g fill="#333"><path d="M4 4h16v16H4z" /></g></svg>';
|
||||
expect(isMonochromeSvg(svg)).toBe(true);
|
||||
|
|
|
|||
|
|
@ -35,8 +35,11 @@ const GRAY_LEVELS = new Map<string, number>([
|
|||
/** Paint properties whose color values determine whether an SVG is monochrome. */
|
||||
const PAINT_PROPS = ['fill', 'stroke', 'stop-color'];
|
||||
|
||||
/** Area shapes that render with SVG's default black fill when none is supplied. */
|
||||
const FILLABLE_SHAPES = 'path, rect, circle, ellipse, polygon, text';
|
||||
/**
|
||||
* Shapes that render with SVG's default black fill when none is supplied. Includes
|
||||
* `polyline` (SVG closes it for fill painting) but not `line`, which has no area.
|
||||
*/
|
||||
const FILLABLE_SHAPES = 'path, rect, circle, ellipse, polygon, polyline, text';
|
||||
|
||||
/**
|
||||
* Containers whose descendants supply functional paint (clipping, masking,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue