@@ -24,24 +24,21 @@ export default declare(({
24
24
EXPORT_FILENAME ,
25
25
SVG_NAME ,
26
26
SVG_CODE ,
27
- SVG_DEFAULT_PROPS_CODE ,
28
27
} ) => {
29
28
const namedTemplate = `
30
29
var SVG_NAME = function SVG_NAME(props) { return SVG_CODE; };
31
- ${ SVG_DEFAULT_PROPS_CODE ? 'SVG_NAME.defaultProps = SVG_DEFAULT_PROPS_CODE;' : '' }
32
30
${ IS_EXPORT ? 'export { SVG_NAME };' : '' }
33
31
` ;
34
32
const anonymousTemplate = `
35
33
var Component = function (props) { return SVG_CODE; };
36
- ${ SVG_DEFAULT_PROPS_CODE ? 'Component.defaultProps = SVG_DEFAULT_PROPS_CODE;' : '' }
37
34
Component.displayName = 'EXPORT_FILENAME';
38
35
export default Component;
39
36
` ;
40
37
41
38
if ( SVG_NAME !== 'default' ) {
42
- return template ( namedTemplate ) ( { SVG_NAME , SVG_CODE , SVG_DEFAULT_PROPS_CODE } ) ;
39
+ return template ( namedTemplate ) ( { SVG_NAME , SVG_CODE } ) ;
43
40
}
44
- return template ( anonymousTemplate ) ( { SVG_CODE , SVG_DEFAULT_PROPS_CODE , EXPORT_FILENAME } ) ;
41
+ return template ( anonymousTemplate ) ( { SVG_CODE , EXPORT_FILENAME } ) ;
45
42
} ;
46
43
47
44
function applyPlugin ( importIdentifier , importPath , path , state , isExport , exportFilename ) {
@@ -95,32 +92,8 @@ export default declare(({
95
92
EXPORT_FILENAME : exportFilename ,
96
93
} ;
97
94
98
- // Move props off of element and into defaultProps
99
- if ( svgCode . openingElement . attributes . length > 1 ) {
100
- const keepProps = [ ] ;
101
- const defaultProps = [ ] ;
102
-
103
- svgCode . openingElement . attributes . forEach ( ( prop ) => {
104
- if ( prop . type === 'JSXSpreadAttribute' ) {
105
- keepProps . push ( prop ) ;
106
- } else if ( prop . value . type === 'JSXExpressionContainer' ) {
107
- const objectExpression = t . objectExpression ( prop . value . expression . properties ) ;
108
- defaultProps . push ( t . objectProperty ( t . identifier ( prop . name . name ) , objectExpression ) ) ;
109
- } else {
110
- defaultProps . push ( t . objectProperty ( t . identifier ( prop . name . name ) , prop . value ) ) ;
111
- }
112
- } ) ;
113
-
114
- svgCode . openingElement . attributes = keepProps ;
115
- opts . SVG_DEFAULT_PROPS_CODE = t . objectExpression ( defaultProps ) ;
116
- }
117
-
118
95
const svgReplacement = buildSvg ( opts ) ;
119
- if ( opts . SVG_DEFAULT_PROPS_CODE ) {
120
- [ newPath ] = path . replaceWithMultiple ( svgReplacement ) ;
121
- } else {
122
- newPath = path . replaceWith ( svgReplacement ) ;
123
- }
96
+ [ newPath ] = path . replaceWithMultiple ( svgReplacement ) ;
124
97
125
98
file . get ( 'ensureReact' ) ( ) ;
126
99
file . set ( 'ensureReact' , ( ) => { } ) ;
0 commit comments