1
0
mirror of https://github.com/svg/svgo.git synced 2025-08-07 15:22:54 +03:00

Add xmlns:xlink in reusePaths plugin (#1555)

Ref https://github.com/svg/svgo/issues/1200
This commit is contained in:
Bogdan Chadkin
2021-09-03 20:57:01 +03:00
committed by GitHub
parent 1e5236d813
commit fab4b255c7
4 changed files with 6 additions and 3 deletions

View File

@@ -101,6 +101,9 @@ exports.fn = () => {
} }
} }
if (defsTag.children.length !== 0) { if (defsTag.children.length !== 0) {
if (node.attributes['xmlns:xlink'] == null) {
node.attributes['xmlns:xlink'] = 'http://www.w3.org/1999/xlink';
}
node.children.unshift(defsTag); node.children.unshift(defsTag);
} }
} }

View File

@@ -16,7 +16,7 @@
@@@ @@@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs> <defs>
<path id="test0" d="M 10,50 l 20,30 L 20,30"/> <path id="test0" d="M 10,50 l 20,30 L 20,30"/>
<path d="M 10,50 c 20,30 40,50 60,70 C 20,30 40,50 60,70" id="reuse-0"/> <path d="M 10,50 c 20,30 40,50 60,70 C 20,30 40,50 60,70" id="reuse-0"/>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -9,7 +9,7 @@
@@@ @@@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs> <defs>
<path id="test0" d="M 10,50 l 20,30 L 20,30"/> <path id="test0" d="M 10,50 l 20,30 L 20,30"/>
<path id="test2" stroke="blue" d="M 10,50 l 20,30 L 20,30"/> <path id="test2" stroke="blue" d="M 10,50 l 20,30 L 20,30"/>

Before

Width:  |  Height:  |  Size: 909 B

After

Width:  |  Height:  |  Size: 952 B

View File

@@ -10,4 +10,4 @@
<text> <text>
text element text element
</text> </text>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 234 B