react 15.7.0 → 16.0.0-alpha

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