mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-01-12 22:51:09 +08:00
[fix] ColorPropType validation
Check color is of type string before using `indexOf`. Fix #630
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
const isWebColor = (color: string) =>
|
||||
color === 'currentcolor' || color === 'inherit' || color.indexOf('var(') === 0;
|
||||
|
||||
const colorPropType = function(isRequired, props, propName, componentName, location, propFullName) {
|
||||
const normalizeColor = require('normalize-css-color');
|
||||
const color = props[propName];
|
||||
@@ -35,8 +38,8 @@ const colorPropType = function(isRequired, props, propName, componentName, locat
|
||||
return;
|
||||
}
|
||||
|
||||
// Web supports additional color keywords and custom property values
|
||||
if (color === 'currentcolor' || color === 'inherit' || color.indexOf('var(') === 0) {
|
||||
if (typeof color === 'string' && isWebColor(color)) {
|
||||
// Web supports additional color keywords and custom property values. Ignore them.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user