mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-25 12:03:27 +00:00
Fix brush color array handling
This commit is contained in:
@@ -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]];
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user