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

plugins/moveElemsAttrsToGroup: fix inheitable only attrs array (fix #47)

This commit is contained in:
deepsweet
2012-11-23 18:11:21 +04:00
parent 88121c7723
commit 87cdc92b37
10 changed files with 59 additions and 33 deletions

View File

@@ -899,25 +899,51 @@ exports.stylingProps = [
]; ];
// http://www.w3.org/TR/SVG/propidx.html // http://www.w3.org/TR/SVG/propidx.html
exports.nonInheritedAttrs = [ exports.inheritableAttrs = [
'alignment-baseline', 'clip-rule',
'baseline-shift', 'color',
'clip', 'color-interpolation',
'clip-path', 'color-interpolation-filters',
'display', 'color-profile',
'dominant-baseline', 'color-rendering',
'enable-background', 'cursor',
'filter', 'direction',
'flood-color', 'fill',
'flood-opacity', 'fill-opacity',
'lighting-color', 'fill-rule',
'mask', 'font',
'opacity', 'font-family',
'overflow', 'font-size',
'stop-color', 'font-size-adjust',
'stop-opacity', 'font-stretch',
'text-decoration', // TODO: "see prose" 'font-style',
'unicode-bidi' 'font-variant',
'font-weight',
'glyph-orientation-horizontal',
'glyph-orientation-vertical',
'image-rendering',
'kerning',
'letter-spacing',
'marker',
'marker-end',
'marker-mid',
'marker-start',
'pointer-events',
'shape-rendering',
'stroke',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'stroke-opacity',
'stroke-width',
'text-anchor',
'text-rendering',
'transform',
'visibility',
'word-spacing',
'writing-mode'
]; ];
// http://www.w3.org/TR/SVG/single-page.html#types-ColorKeywords // http://www.w3.org/TR/SVG/single-page.html#types-ColorKeywords

View File

@@ -1,4 +1,4 @@
var nonInheritedAttrs = require('./_collections').nonInheritedAttrs; var inheritableAttrs = require('./_collections').inheritableAttrs;
/** /**
* Collapse content's intersected and inheritable * Collapse content's intersected and inheritable
@@ -85,7 +85,7 @@ function intersectInheritableAttrs(a, b) {
for (var n in a) { for (var n in a) {
if ( if (
b.hasOwnProperty(n) && b.hasOwnProperty(n) &&
nonInheritedAttrs.indexOf(n) === -1 && inheritableAttrs.indexOf(n) > -1 &&
a[n].name === b[n].name && a[n].name === b[n].name &&
a[n].value === b[n].value && a[n].value === b[n].value &&
a[n].prefix === b[n].prefix && a[n].prefix === b[n].prefix &&

View File

@@ -1,8 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<g attr1="val1"> <g attr1="val1">
<g attr2="val2"> <g fill="red">
text text
</g> </g>
<circle attr2="val2" attr3="val3"/> <circle fill="red" attr3="val3"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 173 B

View File

@@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<g attr1="val1" attr2="val2"> <g attr1="val1" fill="red">
<g> <g>
text text
</g> </g>

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 162 B

View File

@@ -1,8 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<g attr1="val1"> <g attr1="val1">
<g attr2="val2" attr3="val3"> <g fill="red" color="#000">
text text
</g> </g>
<circle attr2="val2" attr3="val3"/> <circle fill="red" color="#000"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 190 B

After

Width:  |  Height:  |  Size: 186 B

View File

@@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<g attr1="val1" attr2="val2" attr3="val3"> <g attr1="val1" fill="red" color="#000">
<g> <g>
text text
</g> </g>

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 162 B

View File

@@ -1,8 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<g transform="rotate(45)"> <g transform="rotate(45)">
<g transform="scale(2)" attr="val"> <g transform="scale(2)" fill="red">
<path d="..."/> <path d="..."/>
</g> </g>
<circle attr="val" transform="scale(2)"/> <circle fill="red" transform="scale(2)"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 223 B

View File

@@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<g transform="rotate(45) scale(2)" attr="val"> <g transform="rotate(45) scale(2)" fill="red">
<g> <g>
<path d="..."/> <path d="..."/>
</g> </g>

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

@@ -1,8 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<g attr1="val1"> <g attr1="val1">
<g attr2="val2" attr3="val3" opacity="1"> <g fill="red" color="#000" opacity="1">
text text
</g> </g>
<circle attr2="val2" attr3="val3" opacity="1"/> <circle fill="red" color="#000" opacity="1"/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 210 B

View File

@@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<g attr1="val1" attr2="val2" attr3="val3"> <g attr1="val1" fill="red" color="#000">
<g opacity="1"> <g opacity="1">
text text
</g> </g>

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 186 B