react 15.7.0 → 16.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +26 -16
  2. package/PATENTS +33 -0
  3. package/README.md +7 -0
  4. package/dist/react-with-addons.js +3798 -4340
  5. package/dist/react-with-addons.min.js +12 -6
  6. package/dist/react.js +2834 -3191
  7. package/dist/react.min.js +12 -5
  8. package/lib/KeyEscapeUtils.js +5 -3
  9. package/lib/PooledClass.js +5 -3
  10. package/lib/React.js +14 -57
  11. package/lib/ReactAddonsDOMDependencies.js +5 -3
  12. package/lib/ReactAddonsDOMDependenciesUMDShim.js +5 -3
  13. package/lib/ReactBaseClasses.js +9 -13
  14. package/lib/ReactCSSTransitionGroup.js +9 -9
  15. package/lib/ReactCSSTransitionGroupChild.js +118 -134
  16. package/lib/ReactChildren.js +9 -7
  17. package/lib/ReactClass.js +703 -0
  18. package/lib/ReactComponentTreeHook.js +63 -58
  19. package/lib/ReactComponentTreeHookUMDShim.js +5 -3
  20. package/lib/ReactComponentWithPureRenderMixin.js +5 -3
  21. package/lib/ReactCurrentOwner.js +7 -3
  22. package/lib/ReactCurrentOwnerUMDShim.js +5 -3
  23. package/lib/ReactDOMFactories.js +6 -3
  24. package/lib/ReactDebugCurrentFrame.js +53 -0
  25. package/lib/ReactElement.js +9 -7
  26. package/lib/ReactElementSymbol.js +5 -3
  27. package/lib/ReactElementType.js +5 -3
  28. package/lib/ReactElementValidator.js +46 -29
  29. package/lib/ReactFragment.js +5 -3
  30. package/lib/ReactNoopUpdateQueue.js +16 -17
  31. package/lib/ReactPropTypes.js +449 -7
  32. package/lib/ReactPropTypesSecret.js +5 -3
  33. package/lib/ReactStateSetters.js +5 -3
  34. package/lib/ReactTransitionChildMapping.js +5 -3
  35. package/lib/ReactTransitionEvents.js +5 -3
  36. package/lib/ReactTransitionGroup.js +8 -12
  37. package/lib/ReactTypeOfWork.js +26 -0
  38. package/lib/ReactUMDEntry.js +8 -7
  39. package/lib/ReactUMDShim.js +5 -3
  40. package/lib/ReactVersion.js +6 -4
  41. package/lib/ReactWithAddons.js +5 -5
  42. package/lib/ReactWithAddonsUMDEntry.js +8 -7
  43. package/lib/canDefineProperty.js +5 -3
  44. package/lib/checkPropTypes.js +64 -0
  45. package/lib/checkReactTypeSpec.js +10 -72
  46. package/lib/deprecated.js +8 -6
  47. package/lib/flattenChildren.js +5 -3
  48. package/lib/getComponentName.js +35 -0
  49. package/lib/getIteratorFn.js +5 -3
  50. package/lib/getNextDebugID.js +5 -3
  51. package/lib/onlyChild.js +6 -4
  52. package/lib/reactProdInvariant.js +4 -2
  53. package/lib/shallowCompare.js +5 -3
  54. package/lib/sliceChildren.js +5 -3
  55. package/lib/traverseAllChildren.js +20 -29
  56. package/lib/update.js +5 -3
  57. package/package.json +24 -35
  58. package/cjs/react-jsx-dev-runtime.development.js +0 -866
  59. package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
  60. package/cjs/react-jsx-runtime.development.js +0 -888
  61. package/cjs/react-jsx-runtime.production.min.js +0 -10
  62. package/jsx-dev-runtime.js +0 -7
  63. package/jsx-runtime.js +0 -7
  64. package/lib/LinkedStateMixin.js +0 -32
  65. package/lib/ReactComponentTreeDevtool.js +0 -12
  66. package/lib/ReactLink.js +0 -47
  67. package/lib/ReactPropTypeLocationNames.js +0 -22
  68. package/lib/ReactPropTypeLocations.js +0 -10
  69. package/lib/createClass.js +0 -20
  70. package/lib/getNextDebugIDUMDShim.js +0 -15
  71. package/lib/lowPriorityWarning.js +0 -62
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright 2015-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright 2015-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
@@ -13,7 +15,7 @@ var warning = require('fbjs/lib/warning');
13
15
  function warnNoop(publicInstance, callerName) {
14
16
  if (process.env.NODE_ENV !== 'production') {
15
17
  var constructor = publicInstance.constructor;
16
- process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
18
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
17
19
  }
18
20
  }
19
21
 
@@ -21,6 +23,7 @@ function warnNoop(publicInstance, callerName) {
21
23
  * This is the abstract API for an update queue.
22
24
  */
23
25
  var ReactNoopUpdateQueue = {
26
+
24
27
  /**
25
28
  * Checks whether or not this composite component is mounted.
26
29
  * @param {ReactClass} publicInstance The instance we want to test.
@@ -32,16 +35,6 @@ var ReactNoopUpdateQueue = {
32
35
  return false;
33
36
  },
34
37
 
35
- /**
36
- * Enqueue a callback that will be executed after all the pending updates
37
- * have processed.
38
- *
39
- * @param {ReactClass} publicInstance The instance to use as `this` context.
40
- * @param {?function} callback Called after state is updated.
41
- * @internal
42
- */
43
- enqueueCallback: function (publicInstance, callback) {},
44
-
45
38
  /**
46
39
  * Forces an update. This should only be invoked when it is known with
47
40
  * certainty that we are **not** in a DOM transaction.
@@ -53,9 +46,11 @@ var ReactNoopUpdateQueue = {
53
46
  * `componentWillUpdate` and `componentDidUpdate`.
54
47
  *
55
48
  * @param {ReactClass} publicInstance The instance that should rerender.
49
+ * @param {?function} callback Called after component is updated.
50
+ * @param {?string} Name of the calling function in the public API.
56
51
  * @internal
57
52
  */
58
- enqueueForceUpdate: function (publicInstance) {
53
+ enqueueForceUpdate: function (publicInstance, callback, callerName) {
59
54
  warnNoop(publicInstance, 'forceUpdate');
60
55
  },
61
56
 
@@ -68,9 +63,11 @@ var ReactNoopUpdateQueue = {
68
63
  *
69
64
  * @param {ReactClass} publicInstance The instance that should rerender.
70
65
  * @param {object} completeState Next state.
66
+ * @param {?function} callback Called after component is updated.
67
+ * @param {?string} Name of the calling function in the public API.
71
68
  * @internal
72
69
  */
73
- enqueueReplaceState: function (publicInstance, completeState) {
70
+ enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
74
71
  warnNoop(publicInstance, 'replaceState');
75
72
  },
76
73
 
@@ -82,9 +79,11 @@ var ReactNoopUpdateQueue = {
82
79
  *
83
80
  * @param {ReactClass} publicInstance The instance that should rerender.
84
81
  * @param {object} partialState Next partial state to be merged with state.
82
+ * @param {?function} callback Called after component is updated.
83
+ * @param {?string} Name of the calling function in the public API.
85
84
  * @internal
86
85
  */
87
- enqueueSetState: function (publicInstance, partialState) {
86
+ enqueueSetState: function (publicInstance, partialState, callback, callerName) {
88
87
  warnNoop(publicInstance, 'setState');
89
88
  }
90
89
  };
@@ -1,16 +1,458 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
9
11
  'use strict';
10
12
 
11
- var _require = require('./ReactElement'),
12
- isValidElement = _require.isValidElement;
13
+ var _prodInvariant = require('./reactProdInvariant');
13
14
 
14
- var factory = require('prop-types/factory');
15
+ var ReactElement = require('./ReactElement');
16
+ var ReactPropTypesSecret = require('./ReactPropTypesSecret');
15
17
 
16
- module.exports = factory(isValidElement);
18
+ var emptyFunction = require('fbjs/lib/emptyFunction');
19
+ var getIteratorFn = require('./getIteratorFn');
20
+ var invariant = require('fbjs/lib/invariant');
21
+ var warning = require('fbjs/lib/warning');
22
+
23
+ /**
24
+ * Collection of methods that allow declaration and validation of props that are
25
+ * supplied to React components. Example usage:
26
+ *
27
+ * var Props = require('ReactPropTypes');
28
+ * var MyArticle = React.createClass({
29
+ * propTypes: {
30
+ * // An optional string prop named "description".
31
+ * description: Props.string,
32
+ *
33
+ * // A required enum prop named "category".
34
+ * category: Props.oneOf(['News','Photos']).isRequired,
35
+ *
36
+ * // A prop named "dialog" that requires an instance of Dialog.
37
+ * dialog: Props.instanceOf(Dialog).isRequired
38
+ * },
39
+ * render: function() { ... }
40
+ * });
41
+ *
42
+ * A more formal specification of how these methods are used:
43
+ *
44
+ * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
45
+ * decl := ReactPropTypes.{type}(.isRequired)?
46
+ *
47
+ * Each and every declaration produces a function with the same signature. This
48
+ * allows the creation of custom validation functions. For example:
49
+ *
50
+ * var MyLink = React.createClass({
51
+ * propTypes: {
52
+ * // An optional string or URI prop named "href".
53
+ * href: function(props, propName, componentName) {
54
+ * var propValue = props[propName];
55
+ * if (propValue != null && typeof propValue !== 'string' &&
56
+ * !(propValue instanceof URI)) {
57
+ * return new Error(
58
+ * 'Expected a string or an URI for ' + propName + ' in ' +
59
+ * componentName
60
+ * );
61
+ * }
62
+ * }
63
+ * },
64
+ * render: function() {...}
65
+ * });
66
+ *
67
+ * @internal
68
+ */
69
+
70
+ var ANONYMOUS = '<<anonymous>>';
71
+
72
+ var ReactPropTypes;
73
+
74
+ if (process.env.NODE_ENV !== 'production') {
75
+ // Keep in sync with production version below
76
+ ReactPropTypes = {
77
+ array: createPrimitiveTypeChecker('array'),
78
+ bool: createPrimitiveTypeChecker('boolean'),
79
+ func: createPrimitiveTypeChecker('function'),
80
+ number: createPrimitiveTypeChecker('number'),
81
+ object: createPrimitiveTypeChecker('object'),
82
+ string: createPrimitiveTypeChecker('string'),
83
+ symbol: createPrimitiveTypeChecker('symbol'),
84
+
85
+ any: createAnyTypeChecker(),
86
+ arrayOf: createArrayOfTypeChecker,
87
+ element: createElementTypeChecker(),
88
+ instanceOf: createInstanceTypeChecker,
89
+ node: createNodeChecker(),
90
+ objectOf: createObjectOfTypeChecker,
91
+ oneOf: createEnumTypeChecker,
92
+ oneOfType: createUnionTypeChecker,
93
+ shape: createShapeTypeChecker
94
+ };
95
+ } else {
96
+ var productionTypeChecker = function () {
97
+ invariant(false, 'React.PropTypes type checking code is stripped in production.');
98
+ };
99
+ productionTypeChecker.isRequired = productionTypeChecker;
100
+ var getProductionTypeChecker = function () {
101
+ return productionTypeChecker;
102
+ };
103
+ // Keep in sync with development version above
104
+ ReactPropTypes = {
105
+ array: productionTypeChecker,
106
+ bool: productionTypeChecker,
107
+ func: productionTypeChecker,
108
+ number: productionTypeChecker,
109
+ object: productionTypeChecker,
110
+ string: productionTypeChecker,
111
+ symbol: productionTypeChecker,
112
+
113
+ any: productionTypeChecker,
114
+ arrayOf: getProductionTypeChecker,
115
+ element: productionTypeChecker,
116
+ instanceOf: getProductionTypeChecker,
117
+ node: productionTypeChecker,
118
+ objectOf: getProductionTypeChecker,
119
+ oneOf: getProductionTypeChecker,
120
+ oneOfType: getProductionTypeChecker,
121
+ shape: getProductionTypeChecker
122
+ };
123
+ }
124
+
125
+ /**
126
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
127
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
128
+ */
129
+ /*eslint-disable no-self-compare*/
130
+ function is(x, y) {
131
+ // SameValue algorithm
132
+ if (x === y) {
133
+ // Steps 1-5, 7-10
134
+ // Steps 6.b-6.e: +0 != -0
135
+ return x !== 0 || 1 / x === 1 / y;
136
+ } else {
137
+ // Step 6.a: NaN == NaN
138
+ return x !== x && y !== y;
139
+ }
140
+ }
141
+ /*eslint-enable no-self-compare*/
142
+
143
+ /**
144
+ * We use an Error-like object for backward compatibility as people may call
145
+ * PropTypes directly and inspect their output. However, we don't use real
146
+ * Errors anymore. We don't inspect their stack anyway, and creating them
147
+ * is prohibitively expensive if they are created too often, such as what
148
+ * happens in oneOfType() for any type before the one that matched.
149
+ */
150
+ function PropTypeError(message) {
151
+ this.message = message;
152
+ this.stack = '';
153
+ }
154
+ // Make `instanceof Error` still work for returned errors.
155
+ PropTypeError.prototype = Error.prototype;
156
+
157
+ function createChainableTypeChecker(validate) {
158
+ if (process.env.NODE_ENV !== 'production') {
159
+ var manualPropTypeCallCache = {};
160
+ }
161
+ function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
162
+ componentName = componentName || ANONYMOUS;
163
+ propFullName = propFullName || propName;
164
+ if (process.env.NODE_ENV !== 'production') {
165
+ if (secret !== ReactPropTypesSecret && typeof console !== 'undefined') {
166
+ var cacheKey = componentName + ':' + propName;
167
+ if (!manualPropTypeCallCache[cacheKey]) {
168
+ process.env.NODE_ENV !== 'production' ? warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will not work in production with the next major version. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName) : void 0;
169
+ manualPropTypeCallCache[cacheKey] = true;
170
+ }
171
+ }
172
+ }
173
+ if (props[propName] == null) {
174
+ if (isRequired) {
175
+ if (props[propName] === null) {
176
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
177
+ }
178
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
179
+ }
180
+ return null;
181
+ } else {
182
+ return validate(props, propName, componentName, location, propFullName);
183
+ }
184
+ }
185
+
186
+ var chainedCheckType = checkType.bind(null, false);
187
+ chainedCheckType.isRequired = checkType.bind(null, true);
188
+
189
+ return chainedCheckType;
190
+ }
191
+
192
+ function createPrimitiveTypeChecker(expectedType) {
193
+ function validate(props, propName, componentName, location, propFullName, secret) {
194
+ var propValue = props[propName];
195
+ var propType = getPropType(propValue);
196
+ if (propType !== expectedType) {
197
+ // `propValue` being instance of, say, date/regexp, pass the 'object'
198
+ // check, but we can offer a more precise error message here rather than
199
+ // 'of type `object`'.
200
+ var preciseType = getPreciseType(propValue);
201
+
202
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
203
+ }
204
+ return null;
205
+ }
206
+ return createChainableTypeChecker(validate);
207
+ }
208
+
209
+ function createAnyTypeChecker() {
210
+ return createChainableTypeChecker(emptyFunction.thatReturnsNull);
211
+ }
212
+
213
+ function createArrayOfTypeChecker(typeChecker) {
214
+ function validate(props, propName, componentName, location, propFullName) {
215
+ if (typeof typeChecker !== 'function') {
216
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
217
+ }
218
+ var propValue = props[propName];
219
+ if (!Array.isArray(propValue)) {
220
+ var propType = getPropType(propValue);
221
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
222
+ }
223
+ for (var i = 0; i < propValue.length; i++) {
224
+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
225
+ if (error instanceof Error) {
226
+ return error;
227
+ }
228
+ }
229
+ return null;
230
+ }
231
+ return createChainableTypeChecker(validate);
232
+ }
233
+
234
+ function createElementTypeChecker() {
235
+ function validate(props, propName, componentName, location, propFullName) {
236
+ var propValue = props[propName];
237
+ if (!ReactElement.isValidElement(propValue)) {
238
+ var propType = getPropType(propValue);
239
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
240
+ }
241
+ return null;
242
+ }
243
+ return createChainableTypeChecker(validate);
244
+ }
245
+
246
+ function createInstanceTypeChecker(expectedClass) {
247
+ function validate(props, propName, componentName, location, propFullName) {
248
+ if (!(props[propName] instanceof expectedClass)) {
249
+ var expectedClassName = expectedClass.name || ANONYMOUS;
250
+ var actualClassName = getClassName(props[propName]);
251
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
252
+ }
253
+ return null;
254
+ }
255
+ return createChainableTypeChecker(validate);
256
+ }
257
+
258
+ function createEnumTypeChecker(expectedValues) {
259
+ if (!Array.isArray(expectedValues)) {
260
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
261
+ return emptyFunction.thatReturnsNull;
262
+ }
263
+
264
+ function validate(props, propName, componentName, location, propFullName) {
265
+ var propValue = props[propName];
266
+ for (var i = 0; i < expectedValues.length; i++) {
267
+ if (is(propValue, expectedValues[i])) {
268
+ return null;
269
+ }
270
+ }
271
+
272
+ var valuesString = JSON.stringify(expectedValues);
273
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
274
+ }
275
+ return createChainableTypeChecker(validate);
276
+ }
277
+
278
+ function createObjectOfTypeChecker(typeChecker) {
279
+ function validate(props, propName, componentName, location, propFullName) {
280
+ if (typeof typeChecker !== 'function') {
281
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
282
+ }
283
+ var propValue = props[propName];
284
+ var propType = getPropType(propValue);
285
+ if (propType !== 'object') {
286
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
287
+ }
288
+ for (var key in propValue) {
289
+ if (propValue.hasOwnProperty(key)) {
290
+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
291
+ if (error instanceof Error) {
292
+ return error;
293
+ }
294
+ }
295
+ }
296
+ return null;
297
+ }
298
+ return createChainableTypeChecker(validate);
299
+ }
300
+
301
+ function createUnionTypeChecker(arrayOfTypeCheckers) {
302
+ if (!Array.isArray(arrayOfTypeCheckers)) {
303
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
304
+ return emptyFunction.thatReturnsNull;
305
+ }
306
+
307
+ function validate(props, propName, componentName, location, propFullName) {
308
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
309
+ var checker = arrayOfTypeCheckers[i];
310
+ if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
311
+ return null;
312
+ }
313
+ }
314
+
315
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
316
+ }
317
+ return createChainableTypeChecker(validate);
318
+ }
319
+
320
+ function createNodeChecker() {
321
+ function validate(props, propName, componentName, location, propFullName) {
322
+ if (!isNode(props[propName])) {
323
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
324
+ }
325
+ return null;
326
+ }
327
+ return createChainableTypeChecker(validate);
328
+ }
329
+
330
+ function createShapeTypeChecker(shapeTypes) {
331
+ function validate(props, propName, componentName, location, propFullName) {
332
+ var propValue = props[propName];
333
+ var propType = getPropType(propValue);
334
+ if (propType !== 'object') {
335
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
336
+ }
337
+ for (var key in shapeTypes) {
338
+ var checker = shapeTypes[key];
339
+ if (!checker) {
340
+ continue;
341
+ }
342
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
343
+ if (error) {
344
+ return error;
345
+ }
346
+ }
347
+ return null;
348
+ }
349
+ return createChainableTypeChecker(validate);
350
+ }
351
+
352
+ function isNode(propValue) {
353
+ switch (typeof propValue) {
354
+ case 'number':
355
+ case 'string':
356
+ case 'undefined':
357
+ return true;
358
+ case 'boolean':
359
+ return !propValue;
360
+ case 'object':
361
+ if (Array.isArray(propValue)) {
362
+ return propValue.every(isNode);
363
+ }
364
+ if (propValue === null || ReactElement.isValidElement(propValue)) {
365
+ return true;
366
+ }
367
+
368
+ var iteratorFn = getIteratorFn(propValue);
369
+ if (iteratorFn) {
370
+ var iterator = iteratorFn.call(propValue);
371
+ var step;
372
+ if (iteratorFn !== propValue.entries) {
373
+ while (!(step = iterator.next()).done) {
374
+ if (!isNode(step.value)) {
375
+ return false;
376
+ }
377
+ }
378
+ } else {
379
+ // Iterator will provide entry [k,v] tuples rather than values.
380
+ while (!(step = iterator.next()).done) {
381
+ var entry = step.value;
382
+ if (entry) {
383
+ if (!isNode(entry[1])) {
384
+ return false;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ } else {
390
+ return false;
391
+ }
392
+
393
+ return true;
394
+ default:
395
+ return false;
396
+ }
397
+ }
398
+
399
+ function isSymbol(propType, propValue) {
400
+ // Native Symbol.
401
+ if (propType === 'symbol') {
402
+ return true;
403
+ }
404
+
405
+ // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
406
+ if (propValue['@@toStringTag'] === 'Symbol') {
407
+ return true;
408
+ }
409
+
410
+ // Fallback for non-spec compliant Symbols which are polyfilled.
411
+ if (typeof Symbol === 'function' && propValue instanceof Symbol) {
412
+ return true;
413
+ }
414
+
415
+ return false;
416
+ }
417
+
418
+ // Equivalent of `typeof` but with special handling for array and regexp.
419
+ function getPropType(propValue) {
420
+ var propType = typeof propValue;
421
+ if (Array.isArray(propValue)) {
422
+ return 'array';
423
+ }
424
+ if (propValue instanceof RegExp) {
425
+ // Old webkits (at least until Android 4.0) return 'function' rather than
426
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
427
+ // passes PropTypes.object.
428
+ return 'object';
429
+ }
430
+ if (isSymbol(propType, propValue)) {
431
+ return 'symbol';
432
+ }
433
+ return propType;
434
+ }
435
+
436
+ // This handles more types than `getPropType`. Only used for error messages.
437
+ // See `createPrimitiveTypeChecker`.
438
+ function getPreciseType(propValue) {
439
+ var propType = getPropType(propValue);
440
+ if (propType === 'object') {
441
+ if (propValue instanceof Date) {
442
+ return 'date';
443
+ } else if (propValue instanceof RegExp) {
444
+ return 'regexp';
445
+ }
446
+ }
447
+ return propType;
448
+ }
449
+
450
+ // Returns class name of the object, if any.
451
+ function getClassName(propValue) {
452
+ if (!propValue.constructor || !propValue.constructor.name) {
453
+ return ANONYMOUS;
454
+ }
455
+ return propValue.constructor.name;
456
+ }
457
+
458
+ module.exports = ReactPropTypes;