From 091bbd29d821719675b5d8085f4c1d12af1628c6 Mon Sep 17 00:00:00 2001 From: John Kenny Date: Sun, 28 Jan 2024 16:23:56 -0800 Subject: [PATCH] Treat with opacity:0 as non-rendering node. --- plugins/removeHiddenElems.js | 4 ++++ test/plugins/removeHiddenElems.19.svg.txt | 28 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/plugins/removeHiddenElems.19.svg.txt diff --git a/plugins/removeHiddenElems.js b/plugins/removeHiddenElems.js index 995ecff65..79d51504e 100644 --- a/plugins/removeHiddenElems.js +++ b/plugins/removeHiddenElems.js @@ -143,6 +143,10 @@ export const fn = (root, params) => { computedStyle.opacity.type === 'static' && computedStyle.opacity.value === '0' ) { + if (node.name === 'path') { + nonRenderedNodes.set(node, parentNode); + return visitSkip; + } removeElement(node, parentNode); } }, diff --git a/test/plugins/removeHiddenElems.19.svg.txt b/test/plugins/removeHiddenElems.19.svg.txt new file mode 100644 index 000000000..7101c1bf4 --- /dev/null +++ b/test/plugins/removeHiddenElems.19.svg.txt @@ -0,0 +1,28 @@ +Preserve referenced path, even when path has opacity=0. + +=== + + + + + + + + this is path 2 + + + + + +@@@ + + + + + + + + this is path 2 + + +