Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removeHiddenElems - treat <path> with opacity:0 as non-rendering node. #1948

Merged
merged 1 commit into from
Jan 29, 2024
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>