Fix brush color array handling

This commit is contained in:
Mikael Sand
2019-01-31 17:37:28 +02:00
parent fe4fd7714a
commit 7203228482
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ import extractColor from './extractColor';
const urlIdPattern = /^url\(#(.+?)\)$/;
export default function extractBrush(colorOrBrush) {
if (colorOrBrush === 'none' || !colorOrBrush) {
if (!colorOrBrush || colorOrBrush === 'none') {
return null;
}
@@ -11,7 +11,7 @@ export default function extractBrush(colorOrBrush) {
return [2];
}
try {
const matched = colorOrBrush.match(urlIdPattern);
const matched = typeof colorOrBrush === 'string' && colorOrBrush.match(urlIdPattern);
// brush
if (matched) {
return [1, matched[1]];
+1 -1
View File
@@ -17,7 +17,7 @@ function percentToFloat(percent) {
) {
return percent.__getAnimatedValue();
}
const matched = percent.match(percentReg);
const matched = typeof percent === 'string' && percent.match(percentReg);
if (!matched) {
console.warn(`"${percent}" is not a valid number or percentage string.`);
return 0;