react 15.6.2 → 16.0.0-alpha.2

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 (63) 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 +3772 -4326
  5. package/dist/react-with-addons.min.js +12 -6
  6. package/dist/react.js +2798 -3167
  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 +11 -46
  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 +704 -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/ReactElement.js +9 -7
  25. package/lib/ReactElementSymbol.js +5 -3
  26. package/lib/ReactElementType.js +5 -3
  27. package/lib/ReactElementValidator.js +15 -14
  28. package/lib/ReactFragment.js +5 -3
  29. package/lib/ReactNoopUpdateQueue.js +16 -17
  30. package/lib/ReactPropTypeLocationNames.js +5 -3
  31. package/lib/ReactPropTypeLocations.js +5 -3
  32. package/lib/ReactPropTypes.js +460 -7
  33. package/lib/ReactPropTypesSecret.js +5 -3
  34. package/lib/ReactStateSetters.js +5 -3
  35. package/lib/ReactTransitionChildMapping.js +5 -3
  36. package/lib/ReactTransitionEvents.js +5 -3
  37. package/lib/ReactTransitionGroup.js +8 -12
  38. package/lib/ReactTypeOfWork.js +26 -0
  39. package/lib/ReactUMDEntry.js +8 -7
  40. package/lib/ReactUMDShim.js +5 -3
  41. package/lib/ReactVersion.js +6 -4
  42. package/lib/ReactWithAddons.js +5 -5
  43. package/lib/ReactWithAddonsUMDEntry.js +8 -7
  44. package/lib/canDefineProperty.js +5 -3
  45. package/lib/checkReactTypeSpec.js +21 -7
  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 +4 -5
  58. package/lib/LinkedStateMixin.js +0 -32
  59. package/lib/ReactComponentTreeDevtool.js +0 -12
  60. package/lib/ReactLink.js +0 -47
  61. package/lib/createClass.js +0 -20
  62. package/lib/getNextDebugIDUMDShim.js +0 -15
  63. package/lib/lowPriorityWarning.js +0 -62
@@ -1,8 +1,10 @@
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
 
@@ -52,7 +54,7 @@ function forEachSingleChild(bookKeeping, child, name) {
52
54
  /**
53
55
  * Iterates through children that are typically specified as `props.children`.
54
56
  *
55
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.foreach
57
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.foreach
56
58
  *
57
59
  * The provided forEachFunc(child, index) will be called for each
58
60
  * leaf child.
@@ -129,7 +131,7 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
129
131
  /**
130
132
  * Maps children that are typically specified as `props.children`.
131
133
  *
132
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.map
134
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.map
133
135
  *
134
136
  * The provided mapFunction(child, key, index) will be called for each
135
137
  * leaf child.
@@ -156,7 +158,7 @@ function forEachSingleChildDummy(traverseContext, child, name) {
156
158
  * Count the number of children that are typically specified as
157
159
  * `props.children`.
158
160
  *
159
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.count
161
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.count
160
162
  *
161
163
  * @param {?*} children Children tree container.
162
164
  * @return {number} The number of children.
@@ -169,7 +171,7 @@ function countChildren(children, context) {
169
171
  * Flatten a children object (typically specified as `props.children`) and
170
172
  * return an array with appropriately re-keyed children.
171
173
  *
172
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.toarray
174
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.toarray
173
175
  */
174
176
  function toArray(children) {
175
177
  var result = [];
@@ -0,0 +1,704 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
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.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _prodInvariant = require('./reactProdInvariant'),
14
+ _assign = require('object-assign');
15
+
16
+ var ReactBaseClasses = require('./ReactBaseClasses');
17
+ var ReactElement = require('./ReactElement');
18
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
19
+ var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
20
+
21
+ var emptyObject = require('fbjs/lib/emptyObject');
22
+ var invariant = require('fbjs/lib/invariant');
23
+ var warning = require('fbjs/lib/warning');
24
+
25
+ var ReactComponent = ReactBaseClasses.Component;
26
+
27
+ var MIXINS_KEY = 'mixins';
28
+
29
+ // Helper function to allow the creation of anonymous functions which do not
30
+ // have .name set to the name of the variable being assigned to.
31
+ function identity(fn) {
32
+ return fn;
33
+ }
34
+
35
+ /**
36
+ * Policies that describe methods in `ReactClassInterface`.
37
+ */
38
+
39
+
40
+ /**
41
+ * Composite components are higher-level components that compose other composite
42
+ * or host components.
43
+ *
44
+ * To create a new type of `ReactClass`, pass a specification of
45
+ * your new class to `React.createClass`. The only requirement of your class
46
+ * specification is that you implement a `render` method.
47
+ *
48
+ * var MyComponent = React.createClass({
49
+ * render: function() {
50
+ * return <div>Hello World</div>;
51
+ * }
52
+ * });
53
+ *
54
+ * The class specification supports a specific protocol of methods that have
55
+ * special meaning (e.g. `render`). See `ReactClassInterface` for
56
+ * more the comprehensive protocol. Any other properties and methods in the
57
+ * class specification will be available on the prototype.
58
+ *
59
+ * @interface ReactClassInterface
60
+ * @internal
61
+ */
62
+ var ReactClassInterface = {
63
+
64
+ /**
65
+ * An array of Mixin objects to include when defining your component.
66
+ *
67
+ * @type {array}
68
+ * @optional
69
+ */
70
+ mixins: 'DEFINE_MANY',
71
+
72
+ /**
73
+ * An object containing properties and methods that should be defined on
74
+ * the component's constructor instead of its prototype (static methods).
75
+ *
76
+ * @type {object}
77
+ * @optional
78
+ */
79
+ statics: 'DEFINE_MANY',
80
+
81
+ /**
82
+ * Definition of prop types for this component.
83
+ *
84
+ * @type {object}
85
+ * @optional
86
+ */
87
+ propTypes: 'DEFINE_MANY',
88
+
89
+ /**
90
+ * Definition of context types for this component.
91
+ *
92
+ * @type {object}
93
+ * @optional
94
+ */
95
+ contextTypes: 'DEFINE_MANY',
96
+
97
+ /**
98
+ * Definition of context types this component sets for its children.
99
+ *
100
+ * @type {object}
101
+ * @optional
102
+ */
103
+ childContextTypes: 'DEFINE_MANY',
104
+
105
+ // ==== Definition methods ====
106
+
107
+ /**
108
+ * Invoked when the component is mounted. Values in the mapping will be set on
109
+ * `this.props` if that prop is not specified (i.e. using an `in` check).
110
+ *
111
+ * This method is invoked before `getInitialState` and therefore cannot rely
112
+ * on `this.state` or use `this.setState`.
113
+ *
114
+ * @return {object}
115
+ * @optional
116
+ */
117
+ getDefaultProps: 'DEFINE_MANY_MERGED',
118
+
119
+ /**
120
+ * Invoked once before the component is mounted. The return value will be used
121
+ * as the initial value of `this.state`.
122
+ *
123
+ * getInitialState: function() {
124
+ * return {
125
+ * isOn: false,
126
+ * fooBaz: new BazFoo()
127
+ * }
128
+ * }
129
+ *
130
+ * @return {object}
131
+ * @optional
132
+ */
133
+ getInitialState: 'DEFINE_MANY_MERGED',
134
+
135
+ /**
136
+ * @return {object}
137
+ * @optional
138
+ */
139
+ getChildContext: 'DEFINE_MANY_MERGED',
140
+
141
+ /**
142
+ * Uses props from `this.props` and state from `this.state` to render the
143
+ * structure of the component.
144
+ *
145
+ * No guarantees are made about when or how often this method is invoked, so
146
+ * it must not have side effects.
147
+ *
148
+ * render: function() {
149
+ * var name = this.props.name;
150
+ * return <div>Hello, {name}!</div>;
151
+ * }
152
+ *
153
+ * @return {ReactComponent}
154
+ * @required
155
+ */
156
+ render: 'DEFINE_ONCE',
157
+
158
+ // ==== Delegate methods ====
159
+
160
+ /**
161
+ * Invoked when the component is initially created and about to be mounted.
162
+ * This may have side effects, but any external subscriptions or data created
163
+ * by this method must be cleaned up in `componentWillUnmount`.
164
+ *
165
+ * @optional
166
+ */
167
+ componentWillMount: 'DEFINE_MANY',
168
+
169
+ /**
170
+ * Invoked when the component has been mounted and has a DOM representation.
171
+ * However, there is no guarantee that the DOM node is in the document.
172
+ *
173
+ * Use this as an opportunity to operate on the DOM when the component has
174
+ * been mounted (initialized and rendered) for the first time.
175
+ *
176
+ * @param {DOMElement} rootNode DOM element representing the component.
177
+ * @optional
178
+ */
179
+ componentDidMount: 'DEFINE_MANY',
180
+
181
+ /**
182
+ * Invoked before the component receives new props.
183
+ *
184
+ * Use this as an opportunity to react to a prop transition by updating the
185
+ * state using `this.setState`. Current props are accessed via `this.props`.
186
+ *
187
+ * componentWillReceiveProps: function(nextProps, nextContext) {
188
+ * this.setState({
189
+ * likesIncreasing: nextProps.likeCount > this.props.likeCount
190
+ * });
191
+ * }
192
+ *
193
+ * NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
194
+ * transition may cause a state change, but the opposite is not true. If you
195
+ * need it, you are probably looking for `componentWillUpdate`.
196
+ *
197
+ * @param {object} nextProps
198
+ * @optional
199
+ */
200
+ componentWillReceiveProps: 'DEFINE_MANY',
201
+
202
+ /**
203
+ * Invoked while deciding if the component should be updated as a result of
204
+ * receiving new props, state and/or context.
205
+ *
206
+ * Use this as an opportunity to `return false` when you're certain that the
207
+ * transition to the new props/state/context will not require a component
208
+ * update.
209
+ *
210
+ * shouldComponentUpdate: function(nextProps, nextState, nextContext) {
211
+ * return !equal(nextProps, this.props) ||
212
+ * !equal(nextState, this.state) ||
213
+ * !equal(nextContext, this.context);
214
+ * }
215
+ *
216
+ * @param {object} nextProps
217
+ * @param {?object} nextState
218
+ * @param {?object} nextContext
219
+ * @return {boolean} True if the component should update.
220
+ * @optional
221
+ */
222
+ shouldComponentUpdate: 'DEFINE_ONCE',
223
+
224
+ /**
225
+ * Invoked when the component is about to update due to a transition from
226
+ * `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
227
+ * and `nextContext`.
228
+ *
229
+ * Use this as an opportunity to perform preparation before an update occurs.
230
+ *
231
+ * NOTE: You **cannot** use `this.setState()` in this method.
232
+ *
233
+ * @param {object} nextProps
234
+ * @param {?object} nextState
235
+ * @param {?object} nextContext
236
+ * @param {ReactReconcileTransaction} transaction
237
+ * @optional
238
+ */
239
+ componentWillUpdate: 'DEFINE_MANY',
240
+
241
+ /**
242
+ * Invoked when the component's DOM representation has been updated.
243
+ *
244
+ * Use this as an opportunity to operate on the DOM when the component has
245
+ * been updated.
246
+ *
247
+ * @param {object} prevProps
248
+ * @param {?object} prevState
249
+ * @param {?object} prevContext
250
+ * @param {DOMElement} rootNode DOM element representing the component.
251
+ * @optional
252
+ */
253
+ componentDidUpdate: 'DEFINE_MANY',
254
+
255
+ /**
256
+ * Invoked when the component is about to be removed from its parent and have
257
+ * its DOM representation destroyed.
258
+ *
259
+ * Use this as an opportunity to deallocate any external resources.
260
+ *
261
+ * NOTE: There is no `componentDidUnmount` since your component will have been
262
+ * destroyed by that point.
263
+ *
264
+ * @optional
265
+ */
266
+ componentWillUnmount: 'DEFINE_MANY',
267
+
268
+ // ==== Advanced methods ====
269
+
270
+ /**
271
+ * Updates the component's currently mounted DOM representation.
272
+ *
273
+ * By default, this implements React's rendering and reconciliation algorithm.
274
+ * Sophisticated clients may wish to override this.
275
+ *
276
+ * @param {ReactReconcileTransaction} transaction
277
+ * @internal
278
+ * @overridable
279
+ */
280
+ updateComponent: 'OVERRIDE_BASE'
281
+
282
+ };
283
+
284
+ /**
285
+ * Mapping from class specification keys to special processing functions.
286
+ *
287
+ * Although these are declared like instance properties in the specification
288
+ * when defining classes using `React.createClass`, they are actually static
289
+ * and are accessible on the constructor instead of the prototype. Despite
290
+ * being static, they must be defined outside of the "statics" key under
291
+ * which all other static methods are defined.
292
+ */
293
+ var RESERVED_SPEC_KEYS = {
294
+ displayName: function (Constructor, displayName) {
295
+ Constructor.displayName = displayName;
296
+ },
297
+ mixins: function (Constructor, mixins) {
298
+ if (mixins) {
299
+ for (var i = 0; i < mixins.length; i++) {
300
+ mixSpecIntoComponent(Constructor, mixins[i]);
301
+ }
302
+ }
303
+ },
304
+ childContextTypes: function (Constructor, childContextTypes) {
305
+ if (process.env.NODE_ENV !== 'production') {
306
+ validateTypeDef(Constructor, childContextTypes, 'childContext');
307
+ }
308
+ Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes);
309
+ },
310
+ contextTypes: function (Constructor, contextTypes) {
311
+ if (process.env.NODE_ENV !== 'production') {
312
+ validateTypeDef(Constructor, contextTypes, 'context');
313
+ }
314
+ Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes);
315
+ },
316
+ /**
317
+ * Special case getDefaultProps which should move into statics but requires
318
+ * automatic merging.
319
+ */
320
+ getDefaultProps: function (Constructor, getDefaultProps) {
321
+ if (Constructor.getDefaultProps) {
322
+ Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
323
+ } else {
324
+ Constructor.getDefaultProps = getDefaultProps;
325
+ }
326
+ },
327
+ propTypes: function (Constructor, propTypes) {
328
+ if (process.env.NODE_ENV !== 'production') {
329
+ validateTypeDef(Constructor, propTypes, 'prop');
330
+ }
331
+ Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);
332
+ },
333
+ statics: function (Constructor, statics) {
334
+ mixStaticSpecIntoComponent(Constructor, statics);
335
+ },
336
+ autobind: function () {} };
337
+
338
+ function validateTypeDef(Constructor, typeDef, location) {
339
+ for (var propName in typeDef) {
340
+ if (typeDef.hasOwnProperty(propName)) {
341
+ // use a warning instead of an invariant so components
342
+ // don't show up in prod but only in __DEV__
343
+ process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0;
344
+ }
345
+ }
346
+ }
347
+
348
+ function validateMethodOverride(isAlreadyDefined, name) {
349
+ var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
350
+
351
+ // Disallow overriding of base class methods unless explicitly allowed.
352
+ if (ReactClassMixin.hasOwnProperty(name)) {
353
+ !(specPolicy === 'OVERRIDE_BASE') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.', name) : _prodInvariant('73', name) : void 0;
354
+ }
355
+
356
+ // Disallow defining methods more than once unless explicitly allowed.
357
+ if (isAlreadyDefined) {
358
+ !(specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('74', name) : void 0;
359
+ }
360
+ }
361
+
362
+ /**
363
+ * Mixin helper which handles policy validation and reserved
364
+ * specification keys when building React classes.
365
+ */
366
+ function mixSpecIntoComponent(Constructor, spec) {
367
+ if (!spec) {
368
+ if (process.env.NODE_ENV !== 'production') {
369
+ var typeofSpec = typeof spec;
370
+ var isMixinValid = typeofSpec === 'object' && spec !== null;
371
+
372
+ process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0;
373
+ }
374
+
375
+ return;
376
+ }
377
+
378
+ !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component class or function as a mixin. Instead, just use a regular object.') : _prodInvariant('75') : void 0;
379
+ !!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component as a mixin. Instead, just use a regular object.') : _prodInvariant('76') : void 0;
380
+
381
+ var proto = Constructor.prototype;
382
+ var autoBindPairs = proto.__reactAutoBindPairs;
383
+
384
+ // By handling mixins before any other properties, we ensure the same
385
+ // chaining order is applied to methods with DEFINE_MANY policy, whether
386
+ // mixins are listed before or after these methods in the spec.
387
+ if (spec.hasOwnProperty(MIXINS_KEY)) {
388
+ RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
389
+ }
390
+
391
+ for (var name in spec) {
392
+ if (!spec.hasOwnProperty(name)) {
393
+ continue;
394
+ }
395
+
396
+ if (name === MIXINS_KEY) {
397
+ // We have already handled mixins in a special case above.
398
+ continue;
399
+ }
400
+
401
+ var property = spec[name];
402
+ var isAlreadyDefined = proto.hasOwnProperty(name);
403
+ validateMethodOverride(isAlreadyDefined, name);
404
+
405
+ if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
406
+ RESERVED_SPEC_KEYS[name](Constructor, property);
407
+ } else {
408
+ // Setup methods on prototype:
409
+ // The following member methods should not be automatically bound:
410
+ // 1. Expected ReactClass methods (in the "interface").
411
+ // 2. Overridden methods (that were mixed in).
412
+ var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
413
+ var isFunction = typeof property === 'function';
414
+ var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
415
+
416
+ if (shouldAutoBind) {
417
+ autoBindPairs.push(name, property);
418
+ proto[name] = property;
419
+ } else {
420
+ if (isAlreadyDefined) {
421
+ var specPolicy = ReactClassInterface[name];
422
+
423
+ // These cases should already be caught by validateMethodOverride.
424
+ !(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.', specPolicy, name) : _prodInvariant('77', specPolicy, name) : void 0;
425
+
426
+ // For methods which are defined more than once, call the existing
427
+ // methods before calling the new property, merging if appropriate.
428
+ if (specPolicy === 'DEFINE_MANY_MERGED') {
429
+ proto[name] = createMergedResultFunction(proto[name], property);
430
+ } else if (specPolicy === 'DEFINE_MANY') {
431
+ proto[name] = createChainedFunction(proto[name], property);
432
+ }
433
+ } else {
434
+ proto[name] = property;
435
+ if (process.env.NODE_ENV !== 'production') {
436
+ // Add verbose displayName to the function, which helps when looking
437
+ // at profiling tools.
438
+ if (typeof property === 'function' && spec.displayName) {
439
+ proto[name].displayName = spec.displayName + '_' + name;
440
+ }
441
+ }
442
+ }
443
+ }
444
+ }
445
+ }
446
+ }
447
+
448
+ function mixStaticSpecIntoComponent(Constructor, statics) {
449
+ if (!statics) {
450
+ return;
451
+ }
452
+ for (var name in statics) {
453
+ var property = statics[name];
454
+ if (!statics.hasOwnProperty(name)) {
455
+ continue;
456
+ }
457
+
458
+ var isReserved = name in RESERVED_SPEC_KEYS;
459
+ !!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.', name) : _prodInvariant('78', name) : void 0;
460
+
461
+ var isInherited = name in Constructor;
462
+ !!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('79', name) : void 0;
463
+ Constructor[name] = property;
464
+ }
465
+ }
466
+
467
+ /**
468
+ * Merge two objects, but throw if both contain the same key.
469
+ *
470
+ * @param {object} one The first object, which is mutated.
471
+ * @param {object} two The second object
472
+ * @return {object} one after it has been mutated to contain everything in two.
473
+ */
474
+ function mergeIntoWithNoDuplicateKeys(one, two) {
475
+ !(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : _prodInvariant('80') : void 0;
476
+
477
+ for (var key in two) {
478
+ if (two.hasOwnProperty(key)) {
479
+ !(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.', key) : _prodInvariant('81', key) : void 0;
480
+ one[key] = two[key];
481
+ }
482
+ }
483
+ return one;
484
+ }
485
+
486
+ /**
487
+ * Creates a function that invokes two functions and merges their return values.
488
+ *
489
+ * @param {function} one Function to invoke first.
490
+ * @param {function} two Function to invoke second.
491
+ * @return {function} Function that invokes the two argument functions.
492
+ * @private
493
+ */
494
+ function createMergedResultFunction(one, two) {
495
+ return function mergedResult() {
496
+ var a = one.apply(this, arguments);
497
+ var b = two.apply(this, arguments);
498
+ if (a == null) {
499
+ return b;
500
+ } else if (b == null) {
501
+ return a;
502
+ }
503
+ var c = {};
504
+ mergeIntoWithNoDuplicateKeys(c, a);
505
+ mergeIntoWithNoDuplicateKeys(c, b);
506
+ return c;
507
+ };
508
+ }
509
+
510
+ /**
511
+ * Creates a function that invokes two functions and ignores their return vales.
512
+ *
513
+ * @param {function} one Function to invoke first.
514
+ * @param {function} two Function to invoke second.
515
+ * @return {function} Function that invokes the two argument functions.
516
+ * @private
517
+ */
518
+ function createChainedFunction(one, two) {
519
+ return function chainedFunction() {
520
+ one.apply(this, arguments);
521
+ two.apply(this, arguments);
522
+ };
523
+ }
524
+
525
+ /**
526
+ * Binds a method to the component.
527
+ *
528
+ * @param {object} component Component whose method is going to be bound.
529
+ * @param {function} method Method to be bound.
530
+ * @return {function} The bound method.
531
+ */
532
+ function bindAutoBindMethod(component, method) {
533
+ var boundMethod = method.bind(component);
534
+ if (process.env.NODE_ENV !== 'production') {
535
+ boundMethod.__reactBoundContext = component;
536
+ boundMethod.__reactBoundMethod = method;
537
+ boundMethod.__reactBoundArguments = null;
538
+ var componentName = component.constructor.displayName;
539
+ var _bind = boundMethod.bind;
540
+ boundMethod.bind = function (newThis) {
541
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
542
+ args[_key - 1] = arguments[_key];
543
+ }
544
+
545
+ // User is trying to bind() an autobound method; we effectively will
546
+ // ignore the value of "this" that the user is trying to use, so
547
+ // let's warn.
548
+ if (newThis !== component && newThis !== null) {
549
+ process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance.\n\nSee %s', componentName) : void 0;
550
+ } else if (!args.length) {
551
+ process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call.\n\nSee %s', componentName) : void 0;
552
+ return boundMethod;
553
+ }
554
+ var reboundMethod = _bind.apply(boundMethod, arguments);
555
+ reboundMethod.__reactBoundContext = component;
556
+ reboundMethod.__reactBoundMethod = method;
557
+ reboundMethod.__reactBoundArguments = args;
558
+ return reboundMethod;
559
+ };
560
+ }
561
+ return boundMethod;
562
+ }
563
+
564
+ /**
565
+ * Binds all auto-bound methods in a component.
566
+ *
567
+ * @param {object} component Component whose method is going to be bound.
568
+ */
569
+ function bindAutoBindMethods(component) {
570
+ var pairs = component.__reactAutoBindPairs;
571
+ for (var i = 0; i < pairs.length; i += 2) {
572
+ var autoBindKey = pairs[i];
573
+ var method = pairs[i + 1];
574
+ component[autoBindKey] = bindAutoBindMethod(component, method);
575
+ }
576
+ }
577
+
578
+ /**
579
+ * Add more to the ReactClass base class. These are all legacy features and
580
+ * therefore not already part of the modern ReactComponent.
581
+ */
582
+ var ReactClassMixin = {
583
+
584
+ /**
585
+ * TODO: This will be deprecated because state should always keep a consistent
586
+ * type signature and the only use case for this, is to avoid that.
587
+ */
588
+ replaceState: function (newState, callback) {
589
+ this.updater.enqueueReplaceState(this, newState, callback, 'replaceState');
590
+ },
591
+
592
+ /**
593
+ * Checks whether or not this composite component is mounted.
594
+ * @return {boolean} True if mounted, false otherwise.
595
+ * @protected
596
+ * @final
597
+ */
598
+ isMounted: function () {
599
+ return this.updater.isMounted(this);
600
+ }
601
+ };
602
+
603
+ var ReactClassComponent = function () {};
604
+ _assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
605
+
606
+ /**
607
+ * Module for creating composite components.
608
+ *
609
+ * @class ReactClass
610
+ */
611
+ var ReactClass = {
612
+
613
+ /**
614
+ * Creates a composite component class given a class specification.
615
+ * See https://facebook.github.io/react/docs/react-api.html#createclass
616
+ *
617
+ * @param {object} spec Class specification (which must define `render`).
618
+ * @return {function} Component constructor function.
619
+ * @public
620
+ */
621
+ createClass: function (spec) {
622
+ // To keep our warnings more understandable, we'll use a little hack here to
623
+ // ensure that Constructor.name !== 'Constructor'. This makes sure we don't
624
+ // unnecessarily identify a class without displayName as 'Constructor'.
625
+ var Constructor = identity(function (props, context, updater) {
626
+ // This constructor gets overridden by mocks. The argument is used
627
+ // by mocks to assert on what gets mounted.
628
+
629
+ if (process.env.NODE_ENV !== 'production') {
630
+ process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0;
631
+ }
632
+
633
+ // Wire up auto-binding
634
+ if (this.__reactAutoBindPairs.length) {
635
+ bindAutoBindMethods(this);
636
+ }
637
+
638
+ this.props = props;
639
+ this.context = context;
640
+ this.refs = emptyObject;
641
+ this.updater = updater || ReactNoopUpdateQueue;
642
+
643
+ this.state = null;
644
+
645
+ // ReactClasses doesn't have constructors. Instead, they use the
646
+ // getInitialState and componentWillMount methods for initialization.
647
+
648
+ var initialState = this.getInitialState ? this.getInitialState() : null;
649
+ if (process.env.NODE_ENV !== 'production') {
650
+ // We allow auto-mocks to proceed as if they're returning null.
651
+ if (initialState === undefined && this.getInitialState._isMockFunction) {
652
+ // This is probably bad practice. Consider warning here and
653
+ // deprecating this convenience.
654
+ initialState = null;
655
+ }
656
+ }
657
+ !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : _prodInvariant('82', Constructor.displayName || 'ReactCompositeComponent') : void 0;
658
+
659
+ this.state = initialState;
660
+ });
661
+ Constructor.prototype = new ReactClassComponent();
662
+ Constructor.prototype.constructor = Constructor;
663
+ Constructor.prototype.__reactAutoBindPairs = [];
664
+
665
+ mixSpecIntoComponent(Constructor, spec);
666
+
667
+ // Initialize the defaultProps property after all mixins have been merged.
668
+ if (Constructor.getDefaultProps) {
669
+ Constructor.defaultProps = Constructor.getDefaultProps();
670
+ }
671
+
672
+ if (process.env.NODE_ENV !== 'production') {
673
+ // This is a tag to indicate that the use of these method names is ok,
674
+ // since it's used with createClass. If it's not, then it's likely a
675
+ // mistake so we'll warn you to use the static property, property
676
+ // initializer or constructor respectively.
677
+ if (Constructor.getDefaultProps) {
678
+ Constructor.getDefaultProps.isReactClassApproved = {};
679
+ }
680
+ if (Constructor.prototype.getInitialState) {
681
+ Constructor.prototype.getInitialState.isReactClassApproved = {};
682
+ }
683
+ }
684
+
685
+ !Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : _prodInvariant('83') : void 0;
686
+
687
+ if (process.env.NODE_ENV !== 'production') {
688
+ process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0;
689
+ process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0;
690
+ }
691
+
692
+ // Reduce time spent doing lookups by setting these on the prototype.
693
+ for (var methodName in ReactClassInterface) {
694
+ if (!Constructor.prototype[methodName]) {
695
+ Constructor.prototype[methodName] = null;
696
+ }
697
+ }
698
+
699
+ return Constructor;
700
+ }
701
+
702
+ };
703
+
704
+ module.exports = ReactClass;