mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-01 01:59:10 +00: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
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const isWebColor = (color: string) =>
|
||||||
|
color === 'currentcolor' || color === 'inherit' || color.indexOf('var(') === 0;
|
||||||
|
|
||||||
const colorPropType = function(isRequired, props, propName, componentName, location, propFullName) {
|
const colorPropType = function(isRequired, props, propName, componentName, location, propFullName) {
|
||||||
const normalizeColor = require('normalize-css-color');
|
const normalizeColor = require('normalize-css-color');
|
||||||
const color = props[propName];
|
const color = props[propName];
|
||||||
@@ -35,8 +38,8 @@ const colorPropType = function(isRequired, props, propName, componentName, locat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Web supports additional color keywords and custom property values
|
if (typeof color === 'string' && isWebColor(color)) {
|
||||||
if (color === 'currentcolor' || color === 'inherit' || color.indexOf('var(') === 0) {
|
// Web supports additional color keywords and custom property values. Ignore them.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user