Optimize stroke width extraction.

This commit is contained in:
Mikael Sand
2019-01-06 16:29:30 +02:00
parent 9fa7a4045c
commit a57894a184
2 changed files with 3 additions and 6 deletions
+2 -5
View File
@@ -32,7 +32,7 @@ export default function(props, styleProperties) {
}
}
const { stroke, strokeWidth, strokeDasharray } = props;
const { stroke, strokeWidth = 1, strokeDasharray } = props;
const strokeDash =
!strokeDasharray || strokeDasharray === "none"
? null
@@ -47,10 +47,7 @@ export default function(props, styleProperties) {
strokeDash && strokeDash.length % 2 === 1
? strokeDash.concat(strokeDash)
: strokeDash,
strokeWidth:
!strokeWidth || typeof strokeWidth !== "string"
? String(strokeWidth || 1)
: strokeWidth,
strokeWidth,
strokeDashoffset: strokeDasharray ? +props.strokeDashoffset || 0 : null,
strokeMiterlimit: parseFloat(props.strokeMiterlimit) || 4,
};
+1 -1
View File
@@ -95,7 +95,7 @@ export function setTSpan(TSpanImplementation) {
function getChild(child) {
if (typeof child === "string" || typeof child === "number") {
return <TSpan>{child.toString()}</TSpan>;
return <TSpan>{String(child)}</TSpan>;
} else {
return child;
}