Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugins/removeHiddenElems.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
Expand Down
28 changes: 28 additions & 0 deletions test/plugins/removeHiddenElems.19.svg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Preserve referenced path, even when path has opacity=0.

===

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path id="path2" d="M200 200 l50 -300" style="opacity:0"/>
</defs>
<text style="font-size:24px;">
<textPath xlink:href="#path2">
this is path 2
</textPath>
</text>
<path id="path1" d="M200 200 l50 -300" style="opacity:0"/>
</svg>

@@@

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path id="path2" d="M200 200 l50 -300" style="opacity:0"/>
</defs>
<text style="font-size:24px;">
<textPath xlink:href="#path2">
this is path 2
</textPath>
</text>
</svg>