@@ -5,6 +5,24 @@ const fancyLog = require('fancy-log')
55const PluginError = require ( 'plugin-error' )
66const Vinyl = require ( 'vinyl' )
77
8+ const presentationAttributes = new Set ( [
9+ 'style' , 'alignment-baseline' , 'baseline-shift' , 'clip' , 'clip-path' ,
10+ 'clip-rule' , 'color' , 'color-interpolation' , 'color-interpolation-filters' ,
11+ 'color-profile' , 'color-rendering' , 'cursor' , 'd' , 'direction' , 'display' ,
12+ 'dominant-baseline' , 'enable-background' , 'fill' , 'fill-opacity' , 'fill-rule' ,
13+ 'filter' , 'flood-color' , 'flood-opacity' , 'font-family' , 'font-size' ,
14+ 'font-size-adjust' , 'font-stretch' , 'font-style' , 'font-variant' ,
15+ 'font-weight' , 'glyph-orientation-horizontal' , 'glyph-orientation-vertical' ,
16+ 'image-rendering' , 'kerning' , 'letter-spacing' , 'lighting-color' ,
17+ 'marker-end' , 'marker-mid' , 'marker-start' , 'mask' , 'opacity' , 'overflow' ,
18+ 'pointer-events' , 'shape-rendering' , 'solid-color' , 'solid-opacity' ,
19+ 'stop-color' , 'stop-opacity' , 'stroke' , 'stroke-dasharray' ,
20+ 'stroke-dashoffset' , 'stroke-linecap' , 'stroke-linejoin' , 'stroke-miterlimit' ,
21+ 'stroke-opacity' , 'stroke-width' , 'text-anchor' , 'text-decoration' ,
22+ 'text-rendering' , 'transform' , 'unicode-bidi' , 'vector-effect' , 'visibility' ,
23+ 'word-spacing' , 'writing-mode'
24+ ] ) ;
25+
826module . exports = function ( config ) {
927
1028 config = config || { }
@@ -111,7 +129,19 @@ module.exports = function (config) {
111129 $defs . remove ( )
112130 }
113131
114- $symbol . append ( $svg . contents ( ) )
132+ let $groupWrap = null
133+ for ( let [ name , value ] of Object . entries ( $svg . attr ( ) ) ) {
134+ if ( ! presentationAttributes . has ( name ) ) continue ;
135+ if ( ! $groupWrap ) $groupWrap = $ ( '<g/>' )
136+ $groupWrap . attr ( name , value )
137+ }
138+
139+ if ( $groupWrap ) {
140+ $groupWrap . append ( $svg . contents ( ) )
141+ $symbol . append ( $groupWrap )
142+ } else {
143+ $symbol . append ( $svg . contents ( ) )
144+ }
115145 $combinedSvg . append ( $symbol )
116146 cb ( )
117147 }
0 commit comments