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

Don't remove empty patterns with inheritance

This commit is contained in:
GreLI
2015-04-12 21:08:34 +03:00
parent f651fd8de1
commit d0a5d0e87d
3 changed files with 17 additions and 3 deletions

View File

@ -24,6 +24,7 @@ var container = require('./_collections').elemsGroups.container;
*/
exports.fn = function(item) {
return !(item.isElem(container) && !item.isElem('svg') && item.isEmpty());
return !(item.isElem(container) && !item.isElem('svg') && item.isEmpty() &&
(!item.isElem('pattern') || !item.hasAttr('xlink:href')));
};

View File

@ -1,4 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg">
<pattern/>
<g>
<marker>
<a/>

Before

Width:  |  Height:  |  Size: 211 B

After

Width:  |  Height:  |  Size: 226 B

View File

@ -1,4 +1,10 @@
<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>
<pattern id="a">
<rect/>
</pattern>
<pattern xlink:href="url(#a)" id="b"/>
</defs>
<g>
<marker>
<a/>
@ -9,7 +15,13 @@
@@@
<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>
<pattern id="a">
<rect/>
</pattern>
<pattern xlink:href="url(#a)" id="b"/>
</defs>
<g>
<path d="..."/>
</g>

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 590 B