From d06747abca1e9e652a764db9747395d14f7f6f98 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Thu, 25 Feb 2021 00:05:26 +0300 Subject: [PATCH] Keep hidden elements if any descendant enables visibility --- plugins/removeHiddenElems.js | 4 +++- test/plugins/removeHiddenElems.12.svg | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/plugins/removeHiddenElems.12.svg diff --git a/plugins/removeHiddenElems.js b/plugins/removeHiddenElems.js index dba7a3d15..80d4b601f 100644 --- a/plugins/removeHiddenElems.js +++ b/plugins/removeHiddenElems.js @@ -52,7 +52,9 @@ exports.fn = function (item, params) { // https://www.w3schools.com/cssref/pr_class_visibility.asp if ( params.isHidden && - item.hasAttr('visibility', 'hidden') + item.hasAttr('visibility', 'hidden') && + // keep if any descendant enables visibility + item.querySelector('[visibility=visible]') == null ) return false; // display="none" diff --git a/test/plugins/removeHiddenElems.12.svg b/test/plugins/removeHiddenElems.12.svg new file mode 100644 index 000000000..dee42820f --- /dev/null +++ b/test/plugins/removeHiddenElems.12.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + +@@@ + + + + + + + +