Fix #32  (G elements context bug)
This commit is contained in:
Horcrux
2016-05-13 11:50:03 +08:00
parent ec67d4dae8
commit 91c6115e6e
3 changed files with 25 additions and 10 deletions
+11 -3
View File
@@ -10,6 +10,11 @@ import extractProps from '../lib/extract/extractProps';
class G extends Component{
static displayName = 'G';
static contextTypes = {
svgId: numberProp,
...contextProps
};
static childContextTypes = {
svgId: numberProp,
isInGroup: PropTypes.bool,
@@ -17,13 +22,16 @@ class G extends Component{
};
getChildContext = () => {
return _.reduce(contextProps, (props, value, key) => {
props[key] = this.props[key];
let context = _.reduce(contextProps, (props, value, key) => {
if (!_.isNil(this.props[key])) {
props[key] = this.props[key];
}
return props;
}, {
svgId: this.props.svgId,
svgId: this.props.svgId || this.context.svgId,
isInGroup: true
});
return _.defaults({}, this.context, context);
};
render() {