From 87cdc92b37a80bd3ff7083107f5874497edc8fff Mon Sep 17 00:00:00 2001 From: deepsweet Date: Fri, 23 Nov 2012 18:11:21 +0400 Subject: [PATCH] plugins/moveElemsAttrsToGroup: fix inheitable only attrs array (fix #47) --- plugins/_collections.js | 64 +++++++++++++------ plugins/moveElemsAttrsToGroup.js | 4 +- .../plugins/moveElemsAttrsToGroup.01.orig.svg | 4 +- .../moveElemsAttrsToGroup.01.should.svg | 2 +- .../plugins/moveElemsAttrsToGroup.02.orig.svg | 4 +- .../moveElemsAttrsToGroup.02.should.svg | 2 +- .../plugins/moveElemsAttrsToGroup.04.orig.svg | 4 +- .../moveElemsAttrsToGroup.04.should.svg | 2 +- .../plugins/moveElemsAttrsToGroup.05.orig.svg | 4 +- .../moveElemsAttrsToGroup.05.should.svg | 2 +- 10 files changed, 59 insertions(+), 33 deletions(-) diff --git a/plugins/_collections.js b/plugins/_collections.js index 4bda42b9..e107a619 100644 --- a/plugins/_collections.js +++ b/plugins/_collections.js @@ -899,25 +899,51 @@ exports.stylingProps = [ ]; // http://www.w3.org/TR/SVG/propidx.html -exports.nonInheritedAttrs = [ - 'alignment-baseline', - 'baseline-shift', - 'clip', - 'clip-path', - 'display', - 'dominant-baseline', - 'enable-background', - 'filter', - 'flood-color', - 'flood-opacity', - 'lighting-color', - 'mask', - 'opacity', - 'overflow', - 'stop-color', - 'stop-opacity', - 'text-decoration', // TODO: "see prose" - 'unicode-bidi' +exports.inheritableAttrs = [ + 'clip-rule', + 'color', + 'color-interpolation', + 'color-interpolation-filters', + 'color-profile', + 'color-rendering', + 'cursor', + 'direction', + 'fill', + 'fill-opacity', + 'fill-rule', + 'font', + 'font-family', + 'font-size', + 'font-size-adjust', + 'font-stretch', + 'font-style', + '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 diff --git a/plugins/moveElemsAttrsToGroup.js b/plugins/moveElemsAttrsToGroup.js index d18ba894..a03364fe 100644 --- a/plugins/moveElemsAttrsToGroup.js +++ b/plugins/moveElemsAttrsToGroup.js @@ -1,4 +1,4 @@ -var nonInheritedAttrs = require('./_collections').nonInheritedAttrs; +var inheritableAttrs = require('./_collections').inheritableAttrs; /** * Collapse content's intersected and inheritable @@ -85,7 +85,7 @@ function intersectInheritableAttrs(a, b) { for (var n in a) { if ( b.hasOwnProperty(n) && - nonInheritedAttrs.indexOf(n) === -1 && + inheritableAttrs.indexOf(n) > -1 && a[n].name === b[n].name && a[n].value === b[n].value && a[n].prefix === b[n].prefix && diff --git a/test/plugins/moveElemsAttrsToGroup.01.orig.svg b/test/plugins/moveElemsAttrsToGroup.01.orig.svg index 0766520c..88812805 100644 --- a/test/plugins/moveElemsAttrsToGroup.01.orig.svg +++ b/test/plugins/moveElemsAttrsToGroup.01.orig.svg @@ -1,8 +1,8 @@ - + text - + diff --git a/test/plugins/moveElemsAttrsToGroup.01.should.svg b/test/plugins/moveElemsAttrsToGroup.01.should.svg index 15d1f41a..0d2e748c 100644 --- a/test/plugins/moveElemsAttrsToGroup.01.should.svg +++ b/test/plugins/moveElemsAttrsToGroup.01.should.svg @@ -1,5 +1,5 @@ - + text diff --git a/test/plugins/moveElemsAttrsToGroup.02.orig.svg b/test/plugins/moveElemsAttrsToGroup.02.orig.svg index 4511f1b0..4880eaba 100644 --- a/test/plugins/moveElemsAttrsToGroup.02.orig.svg +++ b/test/plugins/moveElemsAttrsToGroup.02.orig.svg @@ -1,8 +1,8 @@ - + text - + diff --git a/test/plugins/moveElemsAttrsToGroup.02.should.svg b/test/plugins/moveElemsAttrsToGroup.02.should.svg index 12ae6a18..dd6bf4dc 100644 --- a/test/plugins/moveElemsAttrsToGroup.02.should.svg +++ b/test/plugins/moveElemsAttrsToGroup.02.should.svg @@ -1,5 +1,5 @@ - + text diff --git a/test/plugins/moveElemsAttrsToGroup.04.orig.svg b/test/plugins/moveElemsAttrsToGroup.04.orig.svg index e3fae5d7..35938b81 100644 --- a/test/plugins/moveElemsAttrsToGroup.04.orig.svg +++ b/test/plugins/moveElemsAttrsToGroup.04.orig.svg @@ -1,8 +1,8 @@ - + - + diff --git a/test/plugins/moveElemsAttrsToGroup.04.should.svg b/test/plugins/moveElemsAttrsToGroup.04.should.svg index 0b1a2df1..4b28cedf 100644 --- a/test/plugins/moveElemsAttrsToGroup.04.should.svg +++ b/test/plugins/moveElemsAttrsToGroup.04.should.svg @@ -1,5 +1,5 @@ - + diff --git a/test/plugins/moveElemsAttrsToGroup.05.orig.svg b/test/plugins/moveElemsAttrsToGroup.05.orig.svg index f3824d4a..8cf03e87 100644 --- a/test/plugins/moveElemsAttrsToGroup.05.orig.svg +++ b/test/plugins/moveElemsAttrsToGroup.05.orig.svg @@ -1,8 +1,8 @@ - + text - + diff --git a/test/plugins/moveElemsAttrsToGroup.05.should.svg b/test/plugins/moveElemsAttrsToGroup.05.should.svg index 0fcdba06..09a3bcdf 100644 --- a/test/plugins/moveElemsAttrsToGroup.05.should.svg +++ b/test/plugins/moveElemsAttrsToGroup.05.should.svg @@ -1,5 +1,5 @@ - + text