react 0.13.2 → 0.14.0-alpha3

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 (197) hide show
  1. package/README.md +1 -1
  2. package/addons.js +7 -0
  3. package/addons/CSSTransitionGroup.js +1 -0
  4. package/addons/LinkedStateMixin.js +1 -0
  5. package/addons/Perf.js +1 -0
  6. package/addons/PureRenderMixin.js +1 -0
  7. package/addons/TestUtils.js +1 -0
  8. package/addons/TransitionGroup.js +1 -0
  9. package/addons/batchedUpdates.js +1 -0
  10. package/addons/cloneWithProps.js +1 -0
  11. package/addons/createFragment.js +1 -0
  12. package/addons/renderSubtreeIntoContainer.js +1 -0
  13. package/addons/shallowCompare.js +1 -0
  14. package/addons/update.js +1 -0
  15. package/dist/JSXTransformer.js +3355 -1685
  16. package/dist/react-with-addons.js +3320 -5133
  17. package/dist/react-with-addons.min.js +6 -7
  18. package/dist/react.js +2962 -4548
  19. package/dist/react.min.js +5 -5
  20. package/lib/AutoFocusMixin.js +4 -3
  21. package/lib/BeforeInputEventPlugin.js +30 -118
  22. package/lib/CSSCore.js +12 -23
  23. package/lib/CSSProperty.js +4 -3
  24. package/lib/CSSPropertyOperations.js +14 -30
  25. package/lib/CallbackQueue.js +7 -10
  26. package/lib/ChangeEventPlugin.js +24 -88
  27. package/lib/ClientReactRootIndex.js +2 -2
  28. package/lib/DOMChildrenOperations.js +13 -33
  29. package/lib/DOMProperty.js +41 -67
  30. package/lib/DOMPropertyOperations.js +30 -51
  31. package/lib/Danger.js +19 -62
  32. package/lib/DefaultEventPluginOrder.js +2 -12
  33. package/lib/EnterLeaveEventPlugin.js +11 -33
  34. package/lib/EventConstants.js +2 -2
  35. package/lib/EventListener.js +11 -13
  36. package/lib/EventPluginHub.js +44 -47
  37. package/lib/EventPluginRegistry.js +18 -74
  38. package/lib/EventPluginUtils.js +27 -38
  39. package/lib/EventPropagators.js +23 -26
  40. package/lib/ExecutionEnvironment.js +4 -8
  41. package/lib/FallbackCompositionState.js +3 -3
  42. package/lib/HTMLDOMPropertyConfig.js +7 -19
  43. package/lib/LinkedStateMixin.js +3 -6
  44. package/lib/LinkedValueUtils.js +34 -64
  45. package/lib/LocalEventTrapMixin.js +9 -16
  46. package/lib/Object.assign.js +1 -1
  47. package/lib/PooledClass.js +8 -11
  48. package/lib/React.js +9 -129
  49. package/lib/ReactBrowserComponentMixin.js +9 -2
  50. package/lib/ReactBrowserEventEmitter.js +26 -82
  51. package/lib/ReactCSSTransitionGroup.js +13 -24
  52. package/lib/ReactCSSTransitionGroupChild.js +18 -28
  53. package/lib/ReactChildReconciler.js +11 -19
  54. package/lib/ReactChildren.js +21 -28
  55. package/lib/ReactClass.js +81 -234
  56. package/lib/ReactComponent.js +17 -33
  57. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  58. package/lib/ReactComponentEnvironment.js +6 -12
  59. package/lib/ReactComponentWithPureRenderMixin.js +4 -5
  60. package/lib/ReactCompositeComponent.js +87 -311
  61. package/lib/ReactContext.js +2 -44
  62. package/lib/ReactCurrentOwner.js +1 -3
  63. package/lib/ReactDOM.js +4 -2
  64. package/lib/ReactDOMButton.js +3 -4
  65. package/lib/ReactDOMClient.js +85 -0
  66. package/lib/ReactDOMComponent.js +182 -146
  67. package/lib/ReactDOMForm.js +3 -3
  68. package/lib/ReactDOMIDOperations.js +11 -22
  69. package/lib/ReactDOMIframe.js +3 -3
  70. package/lib/ReactDOMImg.js +3 -3
  71. package/lib/ReactDOMInput.js +22 -35
  72. package/lib/ReactDOMOption.js +67 -10
  73. package/lib/ReactDOMSelect.js +50 -28
  74. package/lib/ReactDOMSelection.js +5 -20
  75. package/lib/ReactDOMServer.js +24 -0
  76. package/lib/ReactDOMTextComponent.js +17 -18
  77. package/lib/ReactDOMTextarea.js +15 -27
  78. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  79. package/lib/ReactDefaultInjection.js +31 -40
  80. package/lib/ReactDefaultPerf.js +36 -69
  81. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  82. package/lib/ReactElement.js +24 -57
  83. package/lib/ReactElementValidator.js +38 -105
  84. package/lib/ReactEmptyComponent.js +7 -11
  85. package/lib/ReactErrorUtils.js +2 -2
  86. package/lib/ReactEventEmitterMixin.js +3 -12
  87. package/lib/ReactEventListener.js +16 -38
  88. package/lib/ReactFragment.js +23 -54
  89. package/lib/ReactInjection.js +1 -1
  90. package/lib/ReactInputSelection.js +11 -21
  91. package/lib/ReactInstanceHandles.js +27 -57
  92. package/lib/ReactInstanceMap.js +5 -5
  93. package/lib/ReactIsomorphic.js +70 -0
  94. package/lib/ReactLifeCycle.js +1 -1
  95. package/lib/ReactLink.js +2 -4
  96. package/lib/ReactMarkupChecksum.js +5 -10
  97. package/lib/ReactMount.js +137 -260
  98. package/lib/ReactMultiChild.js +19 -45
  99. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  100. package/lib/ReactNativeComponent.js +7 -11
  101. package/lib/ReactOwner.js +7 -24
  102. package/lib/ReactPerf.js +8 -12
  103. package/lib/ReactPropTransferer.js +4 -4
  104. package/lib/ReactPropTypeLocationNames.js +2 -2
  105. package/lib/ReactPropTypeLocations.js +1 -1
  106. package/lib/ReactPropTypes.js +41 -61
  107. package/lib/ReactReconcileTransaction.js +9 -34
  108. package/lib/ReactReconciler.js +9 -19
  109. package/lib/ReactRef.js +5 -8
  110. package/lib/ReactRootIndex.js +2 -2
  111. package/lib/ReactServerRendering.js +7 -15
  112. package/lib/ReactServerRenderingTransaction.js +7 -32
  113. package/lib/ReactStateSetters.js +6 -6
  114. package/lib/ReactTestUtils.js +93 -165
  115. package/lib/ReactTransitionChildMapping.js +5 -7
  116. package/lib/ReactTransitionEvents.js +5 -5
  117. package/lib/ReactTransitionGroup.js +30 -52
  118. package/lib/ReactUpdateQueue.js +27 -90
  119. package/lib/ReactUpdates.js +27 -79
  120. package/lib/ReactWithAddons.js +7 -6
  121. package/lib/SVGDOMPropertyConfig.js +41 -4
  122. package/lib/SelectEventPlugin.js +28 -29
  123. package/lib/ServerReactRootIndex.js +2 -2
  124. package/lib/SimpleEventPlugin.js +136 -128
  125. package/lib/SyntheticClipboardEvent.js +3 -7
  126. package/lib/SyntheticCompositionEvent.js +3 -9
  127. package/lib/SyntheticDragEvent.js +1 -1
  128. package/lib/SyntheticEvent.js +8 -10
  129. package/lib/SyntheticFocusEvent.js +1 -1
  130. package/lib/SyntheticInputEvent.js +3 -9
  131. package/lib/SyntheticKeyboardEvent.js +4 -4
  132. package/lib/SyntheticMouseEvent.js +8 -14
  133. package/lib/SyntheticTouchEvent.js +1 -1
  134. package/lib/SyntheticUIEvent.js +3 -3
  135. package/lib/SyntheticWheelEvent.js +11 -15
  136. package/lib/Transaction.js +12 -24
  137. package/lib/ViewportMetrics.js +2 -2
  138. package/lib/accumulateInto.js +2 -5
  139. package/lib/adler32.js +2 -4
  140. package/lib/camelize.js +4 -2
  141. package/lib/camelizeStyleName.js +2 -2
  142. package/lib/cloneWithProps.js +5 -11
  143. package/lib/containsNode.js +29 -16
  144. package/lib/createArrayFromMixed.js +17 -16
  145. package/lib/createFullPageComponent.js +4 -11
  146. package/lib/createNodesFromMarkup.js +6 -8
  147. package/lib/dangerousStyleValue.js +2 -3
  148. package/lib/emptyFunction.js +10 -4
  149. package/lib/emptyObject.js +1 -1
  150. package/lib/escapeTextContentForBrowser.js +1 -1
  151. package/lib/findDOMNode.js +5 -24
  152. package/lib/flattenChildren.js +4 -10
  153. package/lib/focusNode.js +2 -3
  154. package/lib/forEachAccumulated.js +2 -2
  155. package/lib/getActiveElement.js +4 -2
  156. package/lib/getEventCharCode.js +1 -1
  157. package/lib/getEventKey.js +1 -1
  158. package/lib/getEventModifierState.js +1 -1
  159. package/lib/getEventTarget.js +1 -1
  160. package/lib/getIteratorFn.js +2 -4
  161. package/lib/getMarkupWrap.js +7 -5
  162. package/lib/getNodeForCharacterOffset.js +1 -1
  163. package/lib/getTextContentAccessor.js +2 -4
  164. package/lib/getUnboundedScrollPosition.js +1 -1
  165. package/lib/hyphenate.js +3 -1
  166. package/lib/hyphenateStyleName.js +2 -2
  167. package/lib/instantiateReactComponent.js +14 -38
  168. package/lib/invariant.js +8 -12
  169. package/lib/isEventSupported.js +7 -10
  170. package/lib/isNode.js +4 -6
  171. package/lib/isTextInputElement.js +2 -4
  172. package/lib/isTextNode.js +3 -1
  173. package/lib/joinClasses.js +2 -2
  174. package/lib/keyMirror.js +3 -6
  175. package/lib/keyOf.js +4 -3
  176. package/lib/mapObject.js +1 -1
  177. package/lib/memoizeStringOnly.js +2 -2
  178. package/lib/onlyChild.js +2 -5
  179. package/lib/performance.js +2 -5
  180. package/lib/performanceNow.js +3 -1
  181. package/lib/quoteAttributeValueForBrowser.js +1 -1
  182. package/lib/renderSubtreeIntoContainer.js +16 -0
  183. package/lib/setInnerHTML.js +11 -8
  184. package/lib/setTextContent.js +3 -3
  185. package/lib/shallowCompare.js +24 -0
  186. package/lib/shallowEqual.js +17 -11
  187. package/lib/shouldUpdateReactComponent.js +3 -64
  188. package/lib/toArray.js +8 -19
  189. package/lib/traverseAllChildren.js +22 -89
  190. package/lib/update.js +25 -85
  191. package/lib/validateDOMNesting.js +363 -0
  192. package/lib/warning.js +17 -15
  193. package/package.json +3 -3
  194. package/lib/MobileSafariClickEventPlugin.js +0 -56
  195. package/lib/ReactPutListenerQueue.js +0 -54
  196. package/lib/cx.js +0 -52
  197. package/lib/getReactRootElementInContainer.js +0 -33
@@ -33,7 +33,7 @@ var ReactChildReconciler = {
33
33
  * @return {?object} A set of child instances.
34
34
  * @internal
35
35
  */
36
- instantiateChildren: function(nestedChildNodes, transaction, context) {
36
+ instantiateChildren: function (nestedChildNodes, transaction, context) {
37
37
  var children = flattenChildren(nestedChildNodes);
38
38
  for (var name in children) {
39
39
  if (children.hasOwnProperty(name)) {
@@ -57,11 +57,7 @@ var ReactChildReconciler = {
57
57
  * @return {?object} A new set of child instances.
58
58
  * @internal
59
59
  */
60
- updateChildren: function(
61
- prevChildren,
62
- nextNestedChildNodes,
63
- transaction,
64
- context) {
60
+ updateChildren: function (prevChildren, nextNestedChildNodes, transaction, context) {
65
61
  // We currently don't have a way to track moves here but if we use iterators
66
62
  // instead of for..in we can zip the iterators and check if an item has
67
63
  // moved.
@@ -80,26 +76,20 @@ var ReactChildReconciler = {
80
76
  var prevElement = prevChild && prevChild._currentElement;
81
77
  var nextElement = nextChildren[name];
82
78
  if (shouldUpdateReactComponent(prevElement, nextElement)) {
83
- ReactReconciler.receiveComponent(
84
- prevChild, nextElement, transaction, context
85
- );
79
+ ReactReconciler.receiveComponent(prevChild, nextElement, transaction, context);
86
80
  nextChildren[name] = prevChild;
87
81
  } else {
88
82
  if (prevChild) {
89
83
  ReactReconciler.unmountComponent(prevChild, name);
90
84
  }
91
85
  // The child must be instantiated before it's mounted.
92
- var nextChildInstance = instantiateReactComponent(
93
- nextElement,
94
- null
95
- );
86
+ var nextChildInstance = instantiateReactComponent(nextElement, null);
96
87
  nextChildren[name] = nextChildInstance;
97
88
  }
98
89
  }
99
90
  // Unmount children that are no longer present.
100
91
  for (name in prevChildren) {
101
- if (prevChildren.hasOwnProperty(name) &&
102
- !(nextChildren && nextChildren.hasOwnProperty(name))) {
92
+ if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
103
93
  ReactReconciler.unmountComponent(prevChildren[name]);
104
94
  }
105
95
  }
@@ -113,13 +103,15 @@ var ReactChildReconciler = {
113
103
  * @param {?object} renderedChildren Previously initialized set of children.
114
104
  * @internal
115
105
  */
116
- unmountChildren: function(renderedChildren) {
106
+ unmountChildren: function (renderedChildren) {
117
107
  for (var name in renderedChildren) {
118
- var renderedChild = renderedChildren[name];
119
- ReactReconciler.unmountComponent(renderedChild);
108
+ if (renderedChildren.hasOwnProperty(name)) {
109
+ var renderedChild = renderedChildren[name];
110
+ ReactReconciler.unmountComponent(renderedChild);
111
+ }
120
112
  }
121
113
  }
122
114
 
123
115
  };
124
116
 
125
- module.exports = ReactChildReconciler;
117
+ module.exports = ReactChildReconciler;
@@ -29,15 +29,15 @@ var threeArgumentPooler = PooledClass.threeArgumentPooler;
29
29
  * @param {?*} forEachContext Context to perform context with.
30
30
  */
31
31
  function ForEachBookKeeping(forEachFunction, forEachContext) {
32
- this.forEachFunction = forEachFunction;
33
- this.forEachContext = forEachContext;
32
+ this.func = forEachFunction;
33
+ this.context = forEachContext;
34
+ this.count = 0;
34
35
  }
35
36
  PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
36
37
 
37
- function forEachSingleChild(traverseContext, child, name, i) {
38
- var forEachBookKeeping = traverseContext;
39
- forEachBookKeeping.forEachFunction.call(
40
- forEachBookKeeping.forEachContext, child, i);
38
+ function forEachSingleChild(traverseContext, child, name) {
39
+ var bookKeeping = traverseContext;
40
+ bookKeeping.func.call(bookKeeping.context, child, bookKeeping.count++);
41
41
  }
42
42
 
43
43
  /**
@@ -55,8 +55,7 @@ function forEachChildren(children, forEachFunc, forEachContext) {
55
55
  return children;
56
56
  }
57
57
 
58
- var traverseContext =
59
- ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
58
+ var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
60
59
  traverseAllChildren(children, forEachSingleChild, traverseContext);
61
60
  ForEachBookKeeping.release(traverseContext);
62
61
  }
@@ -71,30 +70,24 @@ function forEachChildren(children, forEachFunc, forEachContext) {
71
70
  * @param {?*} mapContext Context to perform mapping with.
72
71
  */
73
72
  function MapBookKeeping(mapResult, mapFunction, mapContext) {
74
- this.mapResult = mapResult;
75
- this.mapFunction = mapFunction;
76
- this.mapContext = mapContext;
73
+ this.result = mapResult;
74
+ this.func = mapFunction;
75
+ this.context = mapContext;
76
+ this.count = 0;
77
77
  }
78
78
  PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
79
79
 
80
- function mapSingleChildIntoContext(traverseContext, child, name, i) {
81
- var mapBookKeeping = traverseContext;
82
- var mapResult = mapBookKeeping.mapResult;
83
-
84
- var keyUnique = !mapResult.hasOwnProperty(name);
85
- if ("production" !== process.env.NODE_ENV) {
86
- ("production" !== process.env.NODE_ENV ? warning(
87
- keyUnique,
88
- 'ReactChildren.map(...): Encountered two children with the same key, ' +
89
- '`%s`. Child keys must be unique; when two children share a key, only ' +
90
- 'the first child will be used.',
91
- name
92
- ) : null);
80
+ function mapSingleChildIntoContext(traverseContext, child, name) {
81
+ var bookKeeping = traverseContext;
82
+ var mapResult = bookKeeping.result;
83
+
84
+ var keyUnique = mapResult[name] === undefined;
85
+ if ('production' !== process.env.NODE_ENV) {
86
+ 'production' !== process.env.NODE_ENV ? warning(keyUnique, 'ReactChildren.map(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : undefined;
93
87
  }
94
88
 
95
89
  if (keyUnique) {
96
- var mappedChild =
97
- mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
90
+ var mappedChild = bookKeeping.func.call(bookKeeping.context, child, bookKeeping.count++);
98
91
  mapResult[name] = mappedChild;
99
92
  }
100
93
  }
@@ -125,7 +118,7 @@ function mapChildren(children, func, context) {
125
118
  return ReactFragment.create(mapResult);
126
119
  }
127
120
 
128
- function forEachSingleChildDummy(traverseContext, child, name, i) {
121
+ function forEachSingleChildDummy(traverseContext, child, name) {
129
122
  return null;
130
123
  }
131
124
 
@@ -146,4 +139,4 @@ var ReactChildren = {
146
139
  count: countChildren
147
140
  };
148
141
 
149
- module.exports = ReactChildren;
142
+ module.exports = ReactChildren;
package/lib/ReactClass.js CHANGED
@@ -27,7 +27,7 @@ var keyMirror = require("./keyMirror");
27
27
  var keyOf = require("./keyOf");
28
28
  var warning = require("./warning");
29
29
 
30
- var MIXINS_KEY = keyOf({mixins: null});
30
+ var MIXINS_KEY = keyOf({ mixins: null });
31
31
 
32
32
  /**
33
33
  * Policies that describe methods in `ReactClassInterface`.
@@ -54,7 +54,6 @@ var SpecPolicy = keyMirror({
54
54
  DEFINE_MANY_MERGED: null
55
55
  });
56
56
 
57
-
58
57
  var injectedMixins = [];
59
58
 
60
59
  /**
@@ -74,7 +73,7 @@ var injectedMixins = [];
74
73
  * The class specification supports a specific protocol of methods that have
75
74
  * special meaning (e.g. `render`). See `ReactClassInterface` for
76
75
  * more the comprehensive protocol. Any other properties and methods in the
77
- * class specification will available on the prototype.
76
+ * class specification will be available on the prototype.
78
77
  *
79
78
  * @interface ReactClassInterface
80
79
  * @internal
@@ -176,8 +175,6 @@ var ReactClassInterface = {
176
175
  */
177
176
  render: SpecPolicy.DEFINE_ONCE,
178
177
 
179
-
180
-
181
178
  // ==== Delegate methods ====
182
179
 
183
180
  /**
@@ -288,8 +285,6 @@ var ReactClassInterface = {
288
285
  */
289
286
  componentWillUnmount: SpecPolicy.DEFINE_MANY,
290
287
 
291
-
292
-
293
288
  // ==== Advanced methods ====
294
289
 
295
290
  /**
@@ -316,73 +311,46 @@ var ReactClassInterface = {
316
311
  * which all other static methods are defined.
317
312
  */
318
313
  var RESERVED_SPEC_KEYS = {
319
- displayName: function(Constructor, displayName) {
314
+ displayName: function (Constructor, displayName) {
320
315
  Constructor.displayName = displayName;
321
316
  },
322
- mixins: function(Constructor, mixins) {
317
+ mixins: function (Constructor, mixins) {
323
318
  if (mixins) {
324
319
  for (var i = 0; i < mixins.length; i++) {
325
320
  mixSpecIntoComponent(Constructor, mixins[i]);
326
321
  }
327
322
  }
328
323
  },
329
- childContextTypes: function(Constructor, childContextTypes) {
330
- if ("production" !== process.env.NODE_ENV) {
331
- validateTypeDef(
332
- Constructor,
333
- childContextTypes,
334
- ReactPropTypeLocations.childContext
335
- );
324
+ childContextTypes: function (Constructor, childContextTypes) {
325
+ if ('production' !== process.env.NODE_ENV) {
326
+ validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
336
327
  }
337
- Constructor.childContextTypes = assign(
338
- {},
339
- Constructor.childContextTypes,
340
- childContextTypes
341
- );
328
+ Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes);
342
329
  },
343
- contextTypes: function(Constructor, contextTypes) {
344
- if ("production" !== process.env.NODE_ENV) {
345
- validateTypeDef(
346
- Constructor,
347
- contextTypes,
348
- ReactPropTypeLocations.context
349
- );
330
+ contextTypes: function (Constructor, contextTypes) {
331
+ if ('production' !== process.env.NODE_ENV) {
332
+ validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
350
333
  }
351
- Constructor.contextTypes = assign(
352
- {},
353
- Constructor.contextTypes,
354
- contextTypes
355
- );
334
+ Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes);
356
335
  },
357
336
  /**
358
337
  * Special case getDefaultProps which should move into statics but requires
359
338
  * automatic merging.
360
339
  */
361
- getDefaultProps: function(Constructor, getDefaultProps) {
340
+ getDefaultProps: function (Constructor, getDefaultProps) {
362
341
  if (Constructor.getDefaultProps) {
363
- Constructor.getDefaultProps = createMergedResultFunction(
364
- Constructor.getDefaultProps,
365
- getDefaultProps
366
- );
342
+ Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
367
343
  } else {
368
344
  Constructor.getDefaultProps = getDefaultProps;
369
345
  }
370
346
  },
371
- propTypes: function(Constructor, propTypes) {
372
- if ("production" !== process.env.NODE_ENV) {
373
- validateTypeDef(
374
- Constructor,
375
- propTypes,
376
- ReactPropTypeLocations.prop
377
- );
347
+ propTypes: function (Constructor, propTypes) {
348
+ if ('production' !== process.env.NODE_ENV) {
349
+ validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
378
350
  }
379
- Constructor.propTypes = assign(
380
- {},
381
- Constructor.propTypes,
382
- propTypes
383
- );
351
+ Constructor.propTypes = assign({}, Constructor.propTypes, propTypes);
384
352
  },
385
- statics: function(Constructor, statics) {
353
+ statics: function (Constructor, statics) {
386
354
  mixStaticSpecIntoComponent(Constructor, statics);
387
355
  }
388
356
  };
@@ -392,45 +360,22 @@ function validateTypeDef(Constructor, typeDef, location) {
392
360
  if (typeDef.hasOwnProperty(propName)) {
393
361
  // use a warning instead of an invariant so components
394
362
  // don't show up in prod but not in __DEV__
395
- ("production" !== process.env.NODE_ENV ? warning(
396
- typeof typeDef[propName] === 'function',
397
- '%s: %s type `%s` is invalid; it must be a function, usually from ' +
398
- 'React.PropTypes.',
399
- Constructor.displayName || 'ReactClass',
400
- ReactPropTypeLocationNames[location],
401
- propName
402
- ) : null);
363
+ 'production' !== process.env.NODE_ENV ? 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) : undefined;
403
364
  }
404
365
  }
405
366
  }
406
367
 
407
368
  function validateMethodOverride(proto, name) {
408
- var specPolicy = ReactClassInterface.hasOwnProperty(name) ?
409
- ReactClassInterface[name] :
410
- null;
369
+ var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
411
370
 
412
371
  // Disallow overriding of base class methods unless explicitly allowed.
413
372
  if (ReactClassMixin.hasOwnProperty(name)) {
414
- ("production" !== process.env.NODE_ENV ? invariant(
415
- specPolicy === SpecPolicy.OVERRIDE_BASE,
416
- 'ReactClassInterface: You are attempting to override ' +
417
- '`%s` from your class specification. Ensure that your method names ' +
418
- 'do not overlap with React methods.',
419
- name
420
- ) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE));
373
+ !(specPolicy === SpecPolicy.OVERRIDE_BASE) ? 'production' !== process.env.NODE_ENV ? 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) : invariant(false) : undefined;
421
374
  }
422
375
 
423
376
  // Disallow defining methods more than once unless explicitly allowed.
424
377
  if (proto.hasOwnProperty(name)) {
425
- ("production" !== process.env.NODE_ENV ? invariant(
426
- specPolicy === SpecPolicy.DEFINE_MANY ||
427
- specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
428
- 'ReactClassInterface: You are attempting to define ' +
429
- '`%s` on your component more than once. This conflict may be due ' +
430
- 'to a mixin.',
431
- name
432
- ) : invariant(specPolicy === SpecPolicy.DEFINE_MANY ||
433
- specPolicy === SpecPolicy.DEFINE_MANY_MERGED));
378
+ !(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(false) : undefined;
434
379
  }
435
380
  }
436
381
 
@@ -443,16 +388,8 @@ function mixSpecIntoComponent(Constructor, spec) {
443
388
  return;
444
389
  }
445
390
 
446
- ("production" !== process.env.NODE_ENV ? invariant(
447
- typeof spec !== 'function',
448
- 'ReactClass: You\'re attempting to ' +
449
- 'use a component class as a mixin. Instead, just use a regular object.'
450
- ) : invariant(typeof spec !== 'function'));
451
- ("production" !== process.env.NODE_ENV ? invariant(
452
- !ReactElement.isValidElement(spec),
453
- 'ReactClass: You\'re attempting to ' +
454
- 'use a component as a mixin. Instead, just use a regular object.'
455
- ) : invariant(!ReactElement.isValidElement(spec)));
391
+ !(typeof spec !== 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
392
+ !!ReactElement.isValidElement(spec) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
456
393
 
457
394
  var proto = Constructor.prototype;
458
395
 
@@ -469,7 +406,7 @@ function mixSpecIntoComponent(Constructor, spec) {
469
406
  }
470
407
 
471
408
  if (name === MIXINS_KEY) {
472
- // We have already handled mixins in a special case above
409
+ // We have already handled mixins in a special case above.
473
410
  continue;
474
411
  }
475
412
 
@@ -483,16 +420,10 @@ function mixSpecIntoComponent(Constructor, spec) {
483
420
  // The following member methods should not be automatically bound:
484
421
  // 1. Expected ReactClass methods (in the "interface").
485
422
  // 2. Overridden methods (that were mixed in).
486
- var isReactClassMethod =
487
- ReactClassInterface.hasOwnProperty(name);
423
+ var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
488
424
  var isAlreadyDefined = proto.hasOwnProperty(name);
489
- var markedDontBind = property && property.__reactDontBind;
490
425
  var isFunction = typeof property === 'function';
491
- var shouldAutoBind =
492
- isFunction &&
493
- !isReactClassMethod &&
494
- !isAlreadyDefined &&
495
- !markedDontBind;
426
+ var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined;
496
427
 
497
428
  if (shouldAutoBind) {
498
429
  if (!proto.__reactAutoBindMap) {
@@ -504,18 +435,8 @@ function mixSpecIntoComponent(Constructor, spec) {
504
435
  if (isAlreadyDefined) {
505
436
  var specPolicy = ReactClassInterface[name];
506
437
 
507
- // These cases should already be caught by validateMethodOverride
508
- ("production" !== process.env.NODE_ENV ? invariant(
509
- isReactClassMethod && (
510
- (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
511
- ),
512
- 'ReactClass: Unexpected spec policy %s for key %s ' +
513
- 'when mixing in component specs.',
514
- specPolicy,
515
- name
516
- ) : invariant(isReactClassMethod && (
517
- (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
518
- )));
438
+ // These cases should already be caught by validateMethodOverride.
439
+ !(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(false) : undefined;
519
440
 
520
441
  // For methods which are defined more than once, call the existing
521
442
  // methods before calling the new property, merging if appropriate.
@@ -526,7 +447,7 @@ function mixSpecIntoComponent(Constructor, spec) {
526
447
  }
527
448
  } else {
528
449
  proto[name] = property;
529
- if ("production" !== process.env.NODE_ENV) {
450
+ if ('production' !== process.env.NODE_ENV) {
530
451
  // Add verbose displayName to the function, which helps when looking
531
452
  // at profiling tools.
532
453
  if (typeof property === 'function' && spec.displayName) {
@@ -549,24 +470,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
549
470
  continue;
550
471
  }
551
472
 
552
- var isReserved = name in RESERVED_SPEC_KEYS;
553
- ("production" !== process.env.NODE_ENV ? invariant(
554
- !isReserved,
555
- 'ReactClass: You are attempting to define a reserved ' +
556
- 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
557
- 'as an instance property instead; it will still be accessible on the ' +
558
- 'constructor.',
559
- name
560
- ) : invariant(!isReserved));
561
-
562
- var isInherited = name in Constructor;
563
- ("production" !== process.env.NODE_ENV ? invariant(
564
- !isInherited,
565
- 'ReactClass: You are attempting to define ' +
566
- '`%s` on your component more than once. This conflict may be ' +
567
- 'due to a mixin.',
568
- name
569
- ) : invariant(!isInherited));
473
+ var isReserved = (name in RESERVED_SPEC_KEYS);
474
+ !!isReserved ? 'production' !== process.env.NODE_ENV ? 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) : invariant(false) : undefined;
475
+
476
+ var isInherited = (name in Constructor);
477
+ !!isInherited ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name) : invariant(false) : undefined;
570
478
  Constructor[name] = property;
571
479
  }
572
480
  }
@@ -579,22 +487,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
579
487
  * @return {object} one after it has been mutated to contain everything in two.
580
488
  */
581
489
  function mergeIntoWithNoDuplicateKeys(one, two) {
582
- ("production" !== process.env.NODE_ENV ? invariant(
583
- one && two && typeof one === 'object' && typeof two === 'object',
584
- 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'
585
- ) : invariant(one && two && typeof one === 'object' && typeof two === 'object'));
490
+ !(one && two && typeof one === 'object' && typeof two === 'object') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined;
586
491
 
587
492
  for (var key in two) {
588
493
  if (two.hasOwnProperty(key)) {
589
- ("production" !== process.env.NODE_ENV ? invariant(
590
- one[key] === undefined,
591
- 'mergeIntoWithNoDuplicateKeys(): ' +
592
- 'Tried to merge two objects with the same key: `%s`. This conflict ' +
593
- 'may be due to a mixin; in particular, this may be caused by two ' +
594
- 'getInitialState() or getDefaultProps() methods returning objects ' +
595
- 'with clashing keys.',
596
- key
597
- ) : invariant(one[key] === undefined));
494
+ !(one[key] === undefined) ? 'production' !== process.env.NODE_ENV ? 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) : invariant(false) : undefined;
598
495
  one[key] = two[key];
599
496
  }
600
497
  }
@@ -649,32 +546,25 @@ function createChainedFunction(one, two) {
649
546
  */
650
547
  function bindAutoBindMethod(component, method) {
651
548
  var boundMethod = method.bind(component);
652
- if ("production" !== process.env.NODE_ENV) {
549
+ if ('production' !== process.env.NODE_ENV) {
653
550
  boundMethod.__reactBoundContext = component;
654
551
  boundMethod.__reactBoundMethod = method;
655
552
  boundMethod.__reactBoundArguments = null;
656
553
  var componentName = component.constructor.displayName;
657
554
  var _bind = boundMethod.bind;
658
555
  /* eslint-disable block-scoped-var, no-undef */
659
- boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
556
+ boundMethod.bind = function (newThis) {
557
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
558
+ args[_key - 1] = arguments[_key];
559
+ }
560
+
660
561
  // User is trying to bind() an autobound method; we effectively will
661
562
  // ignore the value of "this" that the user is trying to use, so
662
563
  // let's warn.
663
564
  if (newThis !== component && newThis !== null) {
664
- ("production" !== process.env.NODE_ENV ? warning(
665
- false,
666
- 'bind(): React component methods may only be bound to the ' +
667
- 'component instance. See %s',
668
- componentName
669
- ) : null);
565
+ 'production' !== process.env.NODE_ENV ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined;
670
566
  } else if (!args.length) {
671
- ("production" !== process.env.NODE_ENV ? warning(
672
- false,
673
- 'bind(): You are binding a component method to the component. ' +
674
- 'React does this for you automatically in a high-performance ' +
675
- 'way, so you can safely remove this call. See %s',
676
- componentName
677
- ) : null);
567
+ 'production' !== process.env.NODE_ENV ? 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) : undefined;
678
568
  return boundMethod;
679
569
  }
680
570
  var reboundMethod = _bind.apply(boundMethod, arguments);
@@ -697,27 +587,16 @@ function bindAutoBindMethods(component) {
697
587
  for (var autoBindKey in component.__reactAutoBindMap) {
698
588
  if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
699
589
  var method = component.__reactAutoBindMap[autoBindKey];
700
- component[autoBindKey] = bindAutoBindMethod(
701
- component,
702
- ReactErrorUtils.guard(
703
- method,
704
- component.constructor.displayName + '.' + autoBindKey
705
- )
706
- );
590
+ component[autoBindKey] = bindAutoBindMethod(component, ReactErrorUtils.guard(method, component.constructor.displayName + '.' + autoBindKey));
707
591
  }
708
592
  }
709
593
  }
710
594
 
711
595
  var typeDeprecationDescriptor = {
712
596
  enumerable: false,
713
- get: function() {
597
+ get: function () {
714
598
  var displayName = this.displayName || this.name || 'Component';
715
- ("production" !== process.env.NODE_ENV ? warning(
716
- false,
717
- '%s.type is deprecated. Use %s directly to access the class.',
718
- displayName,
719
- displayName
720
- ) : null);
599
+ 'production' !== process.env.NODE_ENV ? warning(false, '%s.type is deprecated. Use %s directly to access the class.', displayName, displayName) : undefined;
721
600
  Object.defineProperty(this, 'type', {
722
601
  value: this
723
602
  });
@@ -735,7 +614,7 @@ var ReactClassMixin = {
735
614
  * TODO: This will be deprecated because state should always keep a consistent
736
615
  * type signature and the only use case for this, is to avoid that.
737
616
  */
738
- replaceState: function(newState, callback) {
617
+ replaceState: function (newState, callback) {
739
618
  ReactUpdateQueue.enqueueReplaceState(this, newState);
740
619
  if (callback) {
741
620
  ReactUpdateQueue.enqueueCallback(this, callback);
@@ -748,27 +627,20 @@ var ReactClassMixin = {
748
627
  * @protected
749
628
  * @final
750
629
  */
751
- isMounted: function() {
752
- if ("production" !== process.env.NODE_ENV) {
630
+ isMounted: function () {
631
+ if ('production' !== process.env.NODE_ENV) {
753
632
  var owner = ReactCurrentOwner.current;
754
633
  if (owner !== null) {
755
- ("production" !== process.env.NODE_ENV ? warning(
756
- owner._warnedAboutRefsInRender,
757
- '%s is accessing isMounted inside its render() function. ' +
758
- 'render() should be a pure function of props and state. It should ' +
759
- 'never access something that requires stale data from the previous ' +
760
- 'render, such as refs. Move this logic to componentDidMount and ' +
761
- 'componentDidUpdate instead.',
762
- owner.getName() || 'A component'
763
- ) : null);
634
+ 'production' !== process.env.NODE_ENV ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
764
635
  owner._warnedAboutRefsInRender = true;
765
636
  }
766
637
  }
767
638
  var internalInstance = ReactInstanceMap.get(this);
768
- return (
769
- internalInstance &&
770
- internalInstance !== ReactLifeCycle.currentlyMountingInstance
771
- );
639
+ if (internalInstance) {
640
+ return internalInstance !== ReactLifeCycle.currentlyMountingInstance;
641
+ } else {
642
+ return false;
643
+ }
772
644
  },
773
645
 
774
646
  /**
@@ -780,7 +652,7 @@ var ReactClassMixin = {
780
652
  * @public
781
653
  * @deprecated
782
654
  */
783
- setProps: function(partialProps, callback) {
655
+ setProps: function (partialProps, callback) {
784
656
  ReactUpdateQueue.enqueueSetProps(this, partialProps);
785
657
  if (callback) {
786
658
  ReactUpdateQueue.enqueueCallback(this, callback);
@@ -796,7 +668,7 @@ var ReactClassMixin = {
796
668
  * @public
797
669
  * @deprecated
798
670
  */
799
- replaceProps: function(newProps, callback) {
671
+ replaceProps: function (newProps, callback) {
800
672
  ReactUpdateQueue.enqueueReplaceProps(this, newProps);
801
673
  if (callback) {
802
674
  ReactUpdateQueue.enqueueCallback(this, callback);
@@ -804,12 +676,8 @@ var ReactClassMixin = {
804
676
  }
805
677
  };
806
678
 
807
- var ReactClassComponent = function() {};
808
- assign(
809
- ReactClassComponent.prototype,
810
- ReactComponent.prototype,
811
- ReactClassMixin
812
- );
679
+ var ReactClassComponent = function () {};
680
+ assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
813
681
 
814
682
  /**
815
683
  * Module for creating composite components.
@@ -825,17 +693,13 @@ var ReactClass = {
825
693
  * @return {function} Component constructor function.
826
694
  * @public
827
695
  */
828
- createClass: function(spec) {
829
- var Constructor = function(props, context) {
696
+ createClass: function (spec) {
697
+ var Constructor = function (props, context) {
830
698
  // This constructor is overridden by mocks. The argument is used
831
699
  // by mocks to assert on what gets mounted.
832
700
 
833
- if ("production" !== process.env.NODE_ENV) {
834
- ("production" !== process.env.NODE_ENV ? warning(
835
- this instanceof Constructor,
836
- 'Something is calling a React component directly. Use a factory or ' +
837
- 'JSX instead. See: http://fb.me/react-legacyfactory'
838
- ) : null);
701
+ if ('production' !== process.env.NODE_ENV) {
702
+ 'production' !== process.env.NODE_ENV ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined;
839
703
  }
840
704
 
841
705
  // Wire up auto-binding
@@ -851,38 +715,31 @@ var ReactClass = {
851
715
  // getInitialState and componentWillMount methods for initialization.
852
716
 
853
717
  var initialState = this.getInitialState ? this.getInitialState() : null;
854
- if ("production" !== process.env.NODE_ENV) {
718
+ if ('production' !== process.env.NODE_ENV) {
855
719
  // We allow auto-mocks to proceed as if they're returning null.
856
- if (typeof initialState === 'undefined' &&
857
- this.getInitialState._isMockFunction) {
720
+ if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) {
858
721
  // This is probably bad practice. Consider warning here and
859
722
  // deprecating this convenience.
860
723
  initialState = null;
861
724
  }
862
725
  }
863
- ("production" !== process.env.NODE_ENV ? invariant(
864
- typeof initialState === 'object' && !Array.isArray(initialState),
865
- '%s.getInitialState(): must return an object or null',
866
- Constructor.displayName || 'ReactCompositeComponent'
867
- ) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
726
+ !(typeof initialState === 'object' && !Array.isArray(initialState)) ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined;
868
727
 
869
728
  this.state = initialState;
870
729
  };
871
730
  Constructor.prototype = new ReactClassComponent();
872
731
  Constructor.prototype.constructor = Constructor;
873
732
 
874
- injectedMixins.forEach(
875
- mixSpecIntoComponent.bind(null, Constructor)
876
- );
733
+ injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
877
734
 
878
735
  mixSpecIntoComponent(Constructor, spec);
879
736
 
880
- // Initialize the defaultProps property after all mixins have been merged
737
+ // Initialize the defaultProps property after all mixins have been merged.
881
738
  if (Constructor.getDefaultProps) {
882
739
  Constructor.defaultProps = Constructor.getDefaultProps();
883
740
  }
884
741
 
885
- if ("production" !== process.env.NODE_ENV) {
742
+ if ('production' !== process.env.NODE_ENV) {
886
743
  // This is a tag to indicate that the use of these method names is ok,
887
744
  // since it's used with createClass. If it's not, then it's likely a
888
745
  // mistake so we'll warn you to use the static property, property
@@ -895,20 +752,10 @@ var ReactClass = {
895
752
  }
896
753
  }
897
754
 
898
- ("production" !== process.env.NODE_ENV ? invariant(
899
- Constructor.prototype.render,
900
- 'createClass(...): Class specification must implement a `render` method.'
901
- ) : invariant(Constructor.prototype.render));
902
-
903
- if ("production" !== process.env.NODE_ENV) {
904
- ("production" !== process.env.NODE_ENV ? warning(
905
- !Constructor.prototype.componentShouldUpdate,
906
- '%s has a method called ' +
907
- 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
908
- 'The name is phrased as a question because the function is ' +
909
- 'expected to return a value.',
910
- spec.displayName || 'A component'
911
- ) : null);
755
+ !Constructor.prototype.render ? 'production' !== process.env.NODE_ENV ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined;
756
+
757
+ if ('production' !== process.env.NODE_ENV) {
758
+ 'production' !== process.env.NODE_ENV ? 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') : undefined;
912
759
  }
913
760
 
914
761
  // Reduce time spent doing lookups by setting these on the prototype.
@@ -920,19 +767,17 @@ var ReactClass = {
920
767
 
921
768
  // Legacy hook
922
769
  Constructor.type = Constructor;
923
- if ("production" !== process.env.NODE_ENV) {
770
+ if ('production' !== process.env.NODE_ENV) {
924
771
  try {
925
772
  Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
926
- } catch (x) {
927
- // IE will fail on defineProperty (es5-shim/sham too)
928
- }
773
+ } catch (x) {}
929
774
  }
930
775
 
931
776
  return Constructor;
932
777
  },
933
778
 
934
779
  injection: {
935
- injectMixin: function(mixin) {
780
+ injectMixin: function (mixin) {
936
781
  injectedMixins.push(mixin);
937
782
  }
938
783
  }
@@ -940,3 +785,5 @@ var ReactClass = {
940
785
  };
941
786
 
942
787
  module.exports = ReactClass;
788
+
789
+ // IE will fail on defineProperty (es5-shim/sham too)