From be6a694004f042369ca9a4d6142333eaadc0da8a Mon Sep 17 00:00:00 2001 From: John Kenny Date: Sat, 16 Nov 2024 19:47:43 -0800 Subject: [PATCH] feat(removeUnknownsAndDefaults): remove rx/ry = 0 from --- plugins/removeUnknownsAndDefaults.js | 19 +++++++++++++++++ .../removeUnknownsAndDefaults.33.svg.txt | 21 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/plugins/removeUnknownsAndDefaults.33.svg.txt diff --git a/plugins/removeUnknownsAndDefaults.js b/plugins/removeUnknownsAndDefaults.js index a2fe565..bf33951 100644 --- a/plugins/removeUnknownsAndDefaults.js +++ b/plugins/removeUnknownsAndDefaults.js @@ -290,6 +290,25 @@ export const fn = (root, params, info) => { continue; } + // Remove rx/ry = 0 from . + if (element.name === 'rect') { + switch (name) { + case 'rx': + case 'ry': + if (value.toString() === '0') { + const otherValue = + element.attributes[name === 'rx' ? 'ry' : 'rx']; + if ( + otherValue === undefined || + otherValue.toString() === '0' + ) { + delete element.attributes[name]; + continue; + } + } + } + } + // Only remove it if it is either // (a) inheritable, and either // -- a default value, and is not overriding the parent value, or diff --git a/test/plugins/removeUnknownsAndDefaults.33.svg.txt b/test/plugins/removeUnknownsAndDefaults.33.svg.txt new file mode 100644 index 0000000..ed820bb --- /dev/null +++ b/test/plugins/removeUnknownsAndDefaults.33.svg.txt @@ -0,0 +1,21 @@ +Remove rx/ry="0". + +=== + + + + + + + + + +@@@ + + + + + + + +