fix wrong warning about Stop elements

This commit is contained in:
Horcrux
2016-05-09 09:03:56 +08:00
parent 93d6a70f60
commit 04e0858ba7
+8 -6
View File
@@ -29,13 +29,15 @@ class Gradient extends Component{
render(generator) {
let stops = {};
Children.forEach(this.props.children, child => {
if (child.type === Stop && child.props.stopColor && child.props.offset) {
// convert percent to float.
let offset = percentToFloat(child.props.offset);
if (child.type === Stop) {
if (child.props.stopColor && child.props.offset) {
// convert percent to float.
let offset = percentToFloat(child.props.offset);
// add stop
stops[offset] = Color(child.props.stopColor).alpha(+child.props.stopOpacity);
set(this.id, generator.bind(null, stops));
// add stop
stops[offset] = Color(child.props.stopColor).alpha(+child.props.stopOpacity);
set(this.id, generator.bind(null, stops));
}
} else {
console.warn(`'Gradient' can only receive 'Stop' elements as children`);
}