mirror of
https://github.com/svg/svgo.git
synced 2025-07-31 07:44:22 +03:00
Keep hidden elements if any descendant enables visibility
This commit is contained in:
@ -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"
|
||||
|
20
test/plugins/removeHiddenElems.12.svg
Normal file
20
test/plugins/removeHiddenElems.12.svg
Normal file
@ -0,0 +1,20 @@
|
||||
<svg width="480" height="360" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="96" y="96" width="96" height="96" fill="lime" />
|
||||
<g visibility="hidden">
|
||||
<rect x="96" y="96" width="96" height="96" fill="red" />
|
||||
</g>
|
||||
<rect x="196.5" y="196.5" width="95" height="95" fill="red"/>
|
||||
<g visibility="hidden">
|
||||
<rect x="196" y="196" width="96" height="96" fill="lime" visibility="visible" />
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
@@@
|
||||
|
||||
<svg width="480" height="360" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="96" y="96" width="96" height="96" fill="lime"/>
|
||||
<rect x="196.5" y="196.5" width="95" height="95" fill="red"/>
|
||||
<g visibility="hidden">
|
||||
<rect x="196" y="196" width="96" height="96" fill="lime" visibility="visible"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 740 B |
Reference in New Issue
Block a user