Skip to content

Commit 4eafd3e

Browse files
author
Eduardo García Sanz
committed
fixing a nasty bug...
1 parent 9b1ce73 commit 4eafd3e

5 files changed

Lines changed: 33 additions & 11 deletions

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var type = 'svg',
4141
return template
4242
.replace('__TYPE__', type)
4343
.replace(/__NAME__/g, name)
44-
.replace('__SVG__', data.replace('<svg', '<svg {...this.props}'));
44+
.replace('__SVG__', data.replace('<svg', '<svg {...props}'));
4545
};
4646

4747
var transform = function (filename) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"homepage" : "https://github.com/coma/svg-reactify",
55
"repository" : "https://github.com/coma/svg-reactify",
66
"main" : "./index.js",
7-
"version" : "1.0.0",
7+
"version" : "1.0.1",
88
"license" : "MIT",
99
"private" : false,
1010
"authors" : [

template/all.jsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
var React = require('react'),
2-
SVG = __SVG__;
2+
SVG = function (props) {
3+
4+
return __SVG__;
5+
};
36

47
module.exports = React.createClass({
58
displayName: 'svg-__NAME__',
69
propTypes : {
7-
type: React.PropTypes.oneOf(['svg', 'icon'])
10+
type: React.PropTypes.oneOf(['svg', 'icon']),
11+
svg : React.PropTypes.object
812
},
913
getDefaultProps: function() {
1014

1115
return {
12-
type: '__TYPE__'
16+
type: '__TYPE__',
17+
svg : {}
1318
};
1419
},
1520
render : function () {
1621

1722
switch (this.props.type) {
1823

1924
case 'svg':
20-
return SVG;
25+
return SVG(this.props);
2126

2227
case 'icon':
2328

@@ -28,7 +33,7 @@ module.exports = React.createClass({
2833
className += ' ' + this.props.className;
2934
}
3035

31-
return <span { ...this.props } className={ className }>{ SVG }</span>;
36+
return <span { ...this.props } className={ className }>{ SVG(this.props.svg) }</span>;
3237
}
3338
}
3439
});

template/icon.jsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
var React = require('react');
1+
var React = require('react'),
2+
SVG = function (props) {
3+
4+
return __SVG__;
5+
};
26

37
module.exports = React.createClass({
48
displayName: 'svg-__NAME__',
9+
propTypes : {
10+
svg: React.PropTypes.object
11+
},
12+
getDefaultProps: function() {
13+
14+
return {
15+
svg: {}
16+
};
17+
},
518
render : function () {
619

720
var className = 'icon icon-__NAME__';
@@ -11,6 +24,6 @@ module.exports = React.createClass({
1124
className += ' ' + this.props.className;
1225
}
1326

14-
return <span { ...this.props } className={ className }>__SVG__</span>;
27+
return <span { ...this.props } className={ className }>{ SVG(this.props.svg) }</span>;
1528
}
1629
});

template/svg.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
var React = require('react');
1+
var React = require('react'),
2+
SVG = function (props) {
3+
4+
return __SVG__;
5+
};
26

37
module.exports = React.createClass({
48
displayName: 'svg-__NAME__',
59
render : function () {
610

7-
return __SVG__;
11+
return SVG(this.props);
812
}
913
});

0 commit comments

Comments
 (0)