@@ -39,14 +39,18 @@ const ACEPTED_SVG_ELEMENTS = [
39
39
// Attributes from SVG elements that are mapped directly.
40
40
const SVG_ATTS = [ 'viewBox' ] ;
41
41
const G_ATTS = [ 'id' ] ;
42
- const CIRCLE_ATTS = [ 'cx' , 'cy' , 'r' , 'fill' , 'stroke' ] ;
43
- const PATH_ATTS = [ 'd' , 'fill' , 'stroke' ] ;
44
- const RECT_ATTS = [ 'width' , 'height' , 'fill' , 'stroke' , 'x' , 'y' ] ;
42
+ const CIRCLE_ATTS = [ 'cx' , 'cy' , 'r' ] ;
43
+ const PATH_ATTS = [ 'd' ] ;
44
+ const RECT_ATTS = [ 'width' , 'height' ] ;
45
45
const LINEARG_ATTS = [ 'id' , 'x1' , 'y1' , 'x2' , 'y2' ] ;
46
46
const RADIALG_ATTS = [ 'id' , 'cx' , 'cy' , 'r' ] ;
47
47
const STOP_ATTS = [ 'offset' ] ;
48
- const ELLIPSE_ATTS = [ 'fill' , ' cx', 'cy' , 'rx' , 'ry' ] ;
48
+ const ELLIPSE_ATTS = [ 'cx' , 'cy' , 'rx' , 'ry' ] ;
49
49
const POLYGON_ATTS = [ 'points' ] ;
50
+ const POLYLINE_ATTS = [ 'points' ] ;
51
+
52
+ const COMMON_ATTS = [ 'fill' , 'fillOpacity' , 'stroke' , 'strokeWidth' , 'strokeOpacity' , 'strokeLinecap' , 'strokeLinejoin' ,
53
+ 'strokeDasharray' , 'strokeDashoffset' , 'x' , 'y' , 'rotate' , 'scale' , 'origin' , 'originX' , 'originY' ] ;
50
54
51
55
let ind = 0 ;
52
56
@@ -144,6 +148,9 @@ class SvgUri extends Component{
144
148
case 'polygon' :
145
149
componentAtts = this . obtainComponentAtts ( node , POLYGON_ATTS ) ;
146
150
return < Polygon key = { i } { ...componentAtts } > { childs } </ Polygon > ;
151
+ case 'polyline' :
152
+ componentAtts = this . obtainComponentAtts ( node , POLYLINE_ATTS ) ;
153
+ return < Polyline key = { i } { ...componentAtts } > { childs } </ Polyline > ;
147
154
default :
148
155
return null ;
149
156
}
@@ -152,13 +159,13 @@ class SvgUri extends Component{
152
159
obtainComponentAtts ( { attributes} , enabledAttributes ) {
153
160
let styleAtts = { } ;
154
161
Array . from ( attributes ) . forEach ( ( { nodeName, nodeValue} ) => {
155
- Object . assign ( styleAtts , utils . transformStyle ( nodeName , nodeValue , this . props . fill ) ) ;
162
+ Object . assign ( styleAtts , utils . transformStyle ( { nodeName, nodeValue, fillProp : this . props . fill } ) ) ;
156
163
} ) ;
157
164
158
165
let componentAtts = Array . from ( attributes )
159
166
. map ( utils . camelCaseNodeName )
160
167
. map ( utils . removePixelsFromNodeValue )
161
- . filter ( utils . getEnabledAttributes ( enabledAttributes ) )
168
+ . filter ( utils . getEnabledAttributes ( enabledAttributes . concat ( COMMON_ATTS ) ) )
162
169
. reduce ( ( acc , { nodeName, nodeValue} ) => ( {
163
170
...acc ,
164
171
[ nodeName ] : this . props . fill && nodeName === 'fill' ? this . props . fill : nodeValue ,
0 commit comments