Fix PropType for travis
closes #1404
Cheng Lou committed
Apr 14, 2014 at 17:20 UTC
c6df1c2dd2216d3ac3321248758fec13f4478eb2
1 file changed
+8
-2
src/core/ReactPropTypes.js
+8
-2
@@ -281,12 +281,18 @@ function isRenderable(propValue) {
281
}
282
}
283
284
-// Equivalent of `typeof` but with special handling for array.
284
+// Equivalent of `typeof` but with special handling for array and regexp.
285
function getPropType(propValue) {
286
var propType = typeof propValue;
287
if (Array.isArray(propValue)) {
288
return 'array';
289
}
290
+ if (propValue instanceof RegExp) {
291
+ // Old webkits (at least until Android 4.0) return 'function' rather than
292
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
293
+ // passes PropTypes.object.
294
+ return 'object';
295
+ }
296
return propType;
297
}
298
@@ -297,7 +303,7 @@ function getPreciseType(propValue) {
303
if (propType === 'object') {
304
if (propValue instanceof Date) {
305
return 'date';
300
- } else if(propValue instanceof RegExp) {
306
+ } else if (propValue instanceof RegExp) {
307
return 'regexp';
308
}
309
}