From c6df1c2dd2216d3ac3321248758fec13f4478eb2 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Mon, 14 Apr 2014 17:20:20 -0700 Subject: [PATCH] Fix PropType for travis closes #1404 --- src/core/ReactPropTypes.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/ReactPropTypes.js b/src/core/ReactPropTypes.js index a3aa58ff1d..4e8265e15e 100644 --- a/src/core/ReactPropTypes.js +++ b/src/core/ReactPropTypes.js @@ -281,12 +281,18 @@ function isRenderable(propValue) { } } -// Equivalent of `typeof` but with special handling for array. +// Equivalent of `typeof` but with special handling for array and regexp. function getPropType(propValue) { var propType = typeof propValue; if (Array.isArray(propValue)) { return 'array'; } + if (propValue instanceof RegExp) { + // Old webkits (at least until Android 4.0) return 'function' rather than + // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ + // passes PropTypes.object. + return 'object'; + } return propType; } @@ -297,7 +303,7 @@ function getPreciseType(propValue) { if (propType === 'object') { if (propValue instanceof Date) { return 'date'; - } else if(propValue instanceof RegExp) { + } else if (propValue instanceof RegExp) { return 'regexp'; } }