react 0.14.0-alpha1 → 0.14.0-beta2

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 (195) hide show
  1. package/README.md +5 -2
  2. package/addons.js +5 -2
  3. package/dist/JSXTransformer.js +634 -274
  4. package/dist/react-with-addons.js +5376 -4800
  5. package/dist/react-with-addons.min.js +6 -6
  6. package/dist/react.js +5175 -4626
  7. package/dist/react.min.js +6 -5
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
  9. package/lib/BeforeInputEventPlugin.js +13 -13
  10. package/lib/CSSProperty.js +3 -0
  11. package/lib/CSSPropertyOperations.js +13 -13
  12. package/lib/CallbackQueue.js +4 -4
  13. package/lib/ChangeEventPlugin.js +16 -14
  14. package/lib/DOMChildrenOperations.js +10 -6
  15. package/lib/DOMProperty.js +82 -119
  16. package/lib/DOMPropertyOperations.js +78 -33
  17. package/lib/Danger.js +14 -16
  18. package/lib/DefaultEventPluginOrder.js +2 -2
  19. package/lib/EnterLeaveEventPlugin.js +8 -8
  20. package/lib/EventConstants.js +23 -1
  21. package/lib/EventPluginHub.js +13 -13
  22. package/lib/EventPluginRegistry.js +8 -8
  23. package/lib/EventPluginUtils.js +17 -17
  24. package/lib/EventPropagators.js +7 -7
  25. package/lib/FallbackCompositionState.js +3 -3
  26. package/lib/HTMLDOMPropertyConfig.js +14 -5
  27. package/lib/LinkedStateMixin.js +2 -2
  28. package/lib/LinkedValueUtils.js +50 -38
  29. package/lib/MetaMatchers.js +118 -0
  30. package/lib/OrderedMap.js +453 -0
  31. package/lib/PooledClass.js +14 -2
  32. package/lib/React.js +9 -111
  33. package/lib/ReactBrowserComponentMixin.js +4 -4
  34. package/lib/ReactBrowserEventEmitter.js +30 -7
  35. package/lib/ReactCSSTransitionGroup.js +16 -5
  36. package/lib/ReactCSSTransitionGroupChild.js +20 -11
  37. package/lib/ReactChildReconciler.js +25 -18
  38. package/lib/ReactChildren.js +24 -22
  39. package/lib/ReactClass.js +68 -86
  40. package/lib/ReactComponent.js +22 -17
  41. package/lib/ReactComponentBrowserEnvironment.js +2 -4
  42. package/lib/ReactComponentEnvironment.js +2 -2
  43. package/lib/ReactComponentWithPureRenderMixin.js +3 -3
  44. package/lib/ReactCompositeComponent.js +80 -111
  45. package/lib/ReactDOM.js +72 -158
  46. package/lib/ReactDOMButton.js +15 -26
  47. package/lib/ReactDOMComponent.js +384 -62
  48. package/lib/ReactDOMFactories.js +177 -0
  49. package/lib/ReactDOMIDOperations.js +23 -25
  50. package/lib/ReactDOMInput.js +83 -99
  51. package/lib/ReactDOMOption.js +38 -42
  52. package/lib/ReactDOMSelect.js +88 -98
  53. package/lib/ReactDOMSelection.js +3 -3
  54. package/lib/ReactDOMServer.js +24 -0
  55. package/lib/ReactDOMTextComponent.js +13 -13
  56. package/lib/ReactDOMTextarea.js +48 -61
  57. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  58. package/lib/ReactDefaultInjection.js +34 -71
  59. package/lib/ReactDefaultPerf.js +7 -7
  60. package/lib/ReactDefaultPerfAnalysis.js +6 -9
  61. package/lib/ReactElement.js +35 -92
  62. package/lib/ReactElementValidator.js +53 -130
  63. package/lib/ReactEmptyComponent.js +4 -4
  64. package/lib/ReactErrorUtils.js +1 -1
  65. package/lib/ReactEventEmitterMixin.js +3 -4
  66. package/lib/ReactEventListener.js +57 -12
  67. package/lib/ReactFragment.js +22 -17
  68. package/lib/ReactInjection.js +11 -11
  69. package/lib/ReactInputSelection.js +8 -7
  70. package/lib/ReactInstanceHandles.js +12 -12
  71. package/lib/ReactIsomorphic.js +70 -0
  72. package/lib/ReactLink.js +1 -1
  73. package/lib/ReactMarkupChecksum.js +6 -2
  74. package/lib/ReactMount.js +90 -89
  75. package/lib/ReactMultiChild.js +83 -22
  76. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  77. package/lib/ReactNativeComponent.js +3 -8
  78. package/lib/ReactNoopUpdateQueue.js +118 -0
  79. package/lib/ReactOwner.js +3 -3
  80. package/lib/ReactPerf.js +2 -2
  81. package/lib/ReactPropTransferer.js +3 -3
  82. package/lib/ReactPropTypeLocationNames.js +1 -1
  83. package/lib/ReactPropTypeLocations.js +1 -1
  84. package/lib/ReactPropTypes.js +72 -33
  85. package/lib/ReactReconcileTransaction.js +8 -8
  86. package/lib/ReactReconciler.js +18 -20
  87. package/lib/ReactRef.js +1 -1
  88. package/lib/ReactServerBatchingStrategy.js +23 -0
  89. package/lib/ReactServerRendering.js +22 -9
  90. package/lib/ReactServerRenderingTransaction.js +7 -7
  91. package/lib/ReactTestUtils.js +80 -58
  92. package/lib/ReactTransitionChildMapping.js +2 -2
  93. package/lib/ReactTransitionEvents.js +1 -1
  94. package/lib/ReactTransitionGroup.js +5 -6
  95. package/lib/ReactUpdateQueue.js +61 -36
  96. package/lib/ReactUpdates.js +14 -17
  97. package/lib/ReactWithAddons.js +14 -16
  98. package/lib/ResponderEventPlugin.js +514 -0
  99. package/lib/ResponderSyntheticEvent.js +40 -0
  100. package/lib/ResponderTouchHistoryStore.js +180 -0
  101. package/lib/SVGDOMPropertyConfig.js +1 -3
  102. package/lib/SelectEventPlugin.js +14 -15
  103. package/lib/SimpleEventPlugin.js +205 -29
  104. package/lib/SyntheticClipboardEvent.js +3 -3
  105. package/lib/SyntheticCompositionEvent.js +3 -3
  106. package/lib/SyntheticDragEvent.js +3 -3
  107. package/lib/SyntheticEvent.js +9 -8
  108. package/lib/SyntheticFocusEvent.js +3 -3
  109. package/lib/SyntheticInputEvent.js +3 -3
  110. package/lib/SyntheticKeyboardEvent.js +6 -6
  111. package/lib/SyntheticMouseEvent.js +5 -5
  112. package/lib/SyntheticTouchEvent.js +4 -4
  113. package/lib/SyntheticUIEvent.js +4 -4
  114. package/lib/SyntheticWheelEvent.js +3 -3
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +16 -10
  117. package/lib/accumulate.js +44 -0
  118. package/lib/accumulateInto.js +2 -2
  119. package/lib/adler32.js +19 -9
  120. package/lib/cloneWithProps.js +12 -7
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +47 -0
  124. package/lib/findDOMNode.js +11 -12
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/forEachAccumulated.js +1 -1
  127. package/lib/getEventCharCode.js +1 -1
  128. package/lib/getEventKey.js +1 -1
  129. package/lib/getEventModifierState.js +0 -1
  130. package/lib/getTestDocument.js +28 -0
  131. package/lib/getTextContentAccessor.js +1 -1
  132. package/lib/instantiateReactComponent.js +24 -20
  133. package/lib/isEventSupported.js +1 -1
  134. package/lib/isTextInputElement.js +2 -1
  135. package/lib/joinClasses.js +1 -1
  136. package/lib/onlyChild.js +3 -3
  137. package/lib/quoteAttributeValueForBrowser.js +1 -1
  138. package/lib/reactComponentExpect.js +210 -0
  139. package/lib/renderSubtreeIntoContainer.js +1 -1
  140. package/lib/setInnerHTML.js +2 -2
  141. package/lib/setTextContent.js +3 -3
  142. package/lib/shallowCompare.js +1 -1
  143. package/lib/sliceChildren.js +51 -0
  144. package/lib/traverseAllChildren.js +24 -27
  145. package/lib/update.js +13 -13
  146. package/lib/validateDOMNesting.js +199 -100
  147. package/lib/webcomponents.js +6379 -0
  148. package/package.json +4 -6
  149. package/react.js +53 -1
  150. package/addons/CSSTransitionGroup.js +0 -1
  151. package/addons/LinkedStateMixin.js +0 -1
  152. package/addons/Perf.js +0 -1
  153. package/addons/PureRenderMixin.js +0 -1
  154. package/addons/TestUtils.js +0 -1
  155. package/addons/TransitionGroup.js +0 -1
  156. package/addons/batchedUpdates.js +0 -1
  157. package/addons/cloneWithProps.js +0 -1
  158. package/addons/createFragment.js +0 -1
  159. package/addons/renderSubtreeIntoContainer.js +0 -1
  160. package/addons/shallowCompare.js +0 -1
  161. package/addons/update.js +0 -1
  162. package/lib/CSSCore.js +0 -97
  163. package/lib/EventListener.js +0 -84
  164. package/lib/ExecutionEnvironment.js +0 -38
  165. package/lib/LocalEventTrapMixin.js +0 -46
  166. package/lib/ReactContext.js +0 -32
  167. package/lib/ReactDOMForm.js +0 -47
  168. package/lib/ReactDOMIframe.js +0 -43
  169. package/lib/ReactDOMImg.js +0 -44
  170. package/lib/ReactLifeCycle.js +0 -35
  171. package/lib/camelize.js +0 -32
  172. package/lib/camelizeStyleName.js +0 -40
  173. package/lib/containsNode.js +0 -55
  174. package/lib/createArrayFromMixed.js +0 -85
  175. package/lib/createFullPageComponent.js +0 -51
  176. package/lib/createNodesFromMarkup.js +0 -84
  177. package/lib/emptyFunction.js +0 -38
  178. package/lib/emptyObject.js +0 -20
  179. package/lib/focusNode.js +0 -26
  180. package/lib/getActiveElement.js +0 -29
  181. package/lib/getMarkupWrap.js +0 -115
  182. package/lib/getUnboundedScrollPosition.js +0 -38
  183. package/lib/hyphenate.js +0 -33
  184. package/lib/hyphenateStyleName.js +0 -39
  185. package/lib/invariant.js +0 -49
  186. package/lib/isNode.js +0 -23
  187. package/lib/isTextNode.js +0 -25
  188. package/lib/keyMirror.js +0 -48
  189. package/lib/keyOf.js +0 -35
  190. package/lib/mapObject.js +0 -51
  191. package/lib/performance.js +0 -23
  192. package/lib/performanceNow.js +0 -28
  193. package/lib/shallowEqual.js +0 -48
  194. package/lib/toArray.js +0 -57
  195. package/lib/warning.js +0 -61
@@ -11,11 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var PooledClass = require("./PooledClass");
15
- var ReactFragment = require("./ReactFragment");
14
+ var PooledClass = require('./PooledClass');
15
+ var ReactFragment = require('./ReactFragment');
16
16
 
17
- var traverseAllChildren = require("./traverseAllChildren");
18
- var warning = require("./warning");
17
+ var traverseAllChildren = require('./traverseAllChildren');
18
+ var warning = require('fbjs/lib/warning');
19
19
 
20
20
  var twoArgumentPooler = PooledClass.twoArgumentPooler;
21
21
  var threeArgumentPooler = PooledClass.threeArgumentPooler;
@@ -29,14 +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(forEachBookKeeping.forEachContext, child, i);
38
+ function forEachSingleChild(traverseContext, child, name) {
39
+ var bookKeeping = traverseContext;
40
+ bookKeeping.func.call(bookKeeping.context, child, bookKeeping.count++);
40
41
  }
41
42
 
42
43
  /**
@@ -46,7 +47,7 @@ function forEachSingleChild(traverseContext, child, name, i) {
46
47
  * leaf child.
47
48
  *
48
49
  * @param {?*} children Children tree container.
49
- * @param {function(*, int)} forEachFunc.
50
+ * @param {function(*, int)} forEachFunc
50
51
  * @param {*} forEachContext Context for forEachContext.
51
52
  */
52
53
  function forEachChildren(children, forEachFunc, forEachContext) {
@@ -69,23 +70,24 @@ function forEachChildren(children, forEachFunc, forEachContext) {
69
70
  * @param {?*} mapContext Context to perform mapping with.
70
71
  */
71
72
  function MapBookKeeping(mapResult, mapFunction, mapContext) {
72
- this.mapResult = mapResult;
73
- this.mapFunction = mapFunction;
74
- this.mapContext = mapContext;
73
+ this.result = mapResult;
74
+ this.func = mapFunction;
75
+ this.context = mapContext;
76
+ this.count = 0;
75
77
  }
76
78
  PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
77
79
 
78
- function mapSingleChildIntoContext(traverseContext, child, name, i) {
79
- var mapBookKeeping = traverseContext;
80
- var mapResult = mapBookKeeping.mapResult;
80
+ function mapSingleChildIntoContext(traverseContext, child, name) {
81
+ var bookKeeping = traverseContext;
82
+ var mapResult = bookKeeping.result;
81
83
 
82
84
  var keyUnique = mapResult[name] === undefined;
83
- if ('production' !== process.env.NODE_ENV) {
84
- '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) : null;
85
+ if (process.env.NODE_ENV !== 'production') {
86
+ process.env.NODE_ENV !== 'production' ? 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;
85
87
  }
86
88
 
87
89
  if (keyUnique) {
88
- var mappedChild = mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
90
+ var mappedChild = bookKeeping.func.call(bookKeeping.context, child, bookKeeping.count++);
89
91
  mapResult[name] = mappedChild;
90
92
  }
91
93
  }
@@ -100,8 +102,8 @@ function mapSingleChildIntoContext(traverseContext, child, name, i) {
100
102
  * previously relying on the fact that we guarded against null children.
101
103
  *
102
104
  * @param {?*} children Children tree container.
103
- * @param {function(*, int)} mapFunction.
104
- * @param {*} mapContext Context for mapFunction.
105
+ * @param {function(*, int)} func The map function.
106
+ * @param {*} context Context for mapFunction.
105
107
  * @return {object} Object containing the ordered map of results.
106
108
  */
107
109
  function mapChildren(children, func, context) {
@@ -116,7 +118,7 @@ function mapChildren(children, func, context) {
116
118
  return ReactFragment.create(mapResult);
117
119
  }
118
120
 
119
- function forEachSingleChildDummy(traverseContext, child, name, i) {
121
+ function forEachSingleChildDummy(traverseContext, child, name) {
120
122
  return null;
121
123
  }
122
124
 
package/lib/ReactClass.js CHANGED
@@ -11,21 +11,19 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactComponent = require("./ReactComponent");
15
- var ReactCurrentOwner = require("./ReactCurrentOwner");
16
- var ReactElement = require("./ReactElement");
17
- var ReactErrorUtils = require("./ReactErrorUtils");
18
- var ReactInstanceMap = require("./ReactInstanceMap");
19
- var ReactLifeCycle = require("./ReactLifeCycle");
20
- var ReactPropTypeLocations = require("./ReactPropTypeLocations");
21
- var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
22
- var ReactUpdateQueue = require("./ReactUpdateQueue");
23
-
24
- var assign = require("./Object.assign");
25
- var invariant = require("./invariant");
26
- var keyMirror = require("./keyMirror");
27
- var keyOf = require("./keyOf");
28
- var warning = require("./warning");
14
+ var ReactComponent = require('./ReactComponent');
15
+ var ReactElement = require('./ReactElement');
16
+ var ReactErrorUtils = require('./ReactErrorUtils');
17
+ var ReactPropTypeLocations = require('./ReactPropTypeLocations');
18
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
19
+ var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
20
+
21
+ var assign = require('./Object.assign');
22
+ var emptyObject = require('fbjs/lib/emptyObject');
23
+ var invariant = require('fbjs/lib/invariant');
24
+ var keyMirror = require('fbjs/lib/keyMirror');
25
+ var keyOf = require('fbjs/lib/keyOf');
26
+ var warning = require('fbjs/lib/warning');
29
27
 
30
28
  var MIXINS_KEY = keyOf({ mixins: null });
31
29
 
@@ -56,6 +54,14 @@ var SpecPolicy = keyMirror({
56
54
 
57
55
  var injectedMixins = [];
58
56
 
57
+ var warnedSetProps = false;
58
+ function warnSetProps() {
59
+ if (!warnedSetProps) {
60
+ warnedSetProps = true;
61
+ process.env.NODE_ENV !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call React.render again at the top level.') : undefined;
62
+ }
63
+ }
64
+
59
65
  /**
60
66
  * Composite components are higher-level components that compose other composite
61
67
  * or native components.
@@ -322,13 +328,13 @@ var RESERVED_SPEC_KEYS = {
322
328
  }
323
329
  },
324
330
  childContextTypes: function (Constructor, childContextTypes) {
325
- if ('production' !== process.env.NODE_ENV) {
331
+ if (process.env.NODE_ENV !== 'production') {
326
332
  validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
327
333
  }
328
334
  Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes);
329
335
  },
330
336
  contextTypes: function (Constructor, contextTypes) {
331
- if ('production' !== process.env.NODE_ENV) {
337
+ if (process.env.NODE_ENV !== 'production') {
332
338
  validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
333
339
  }
334
340
  Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes);
@@ -345,7 +351,7 @@ var RESERVED_SPEC_KEYS = {
345
351
  }
346
352
  },
347
353
  propTypes: function (Constructor, propTypes) {
348
- if ('production' !== process.env.NODE_ENV) {
354
+ if (process.env.NODE_ENV !== 'production') {
349
355
  validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
350
356
  }
351
357
  Constructor.propTypes = assign({}, Constructor.propTypes, propTypes);
@@ -360,7 +366,7 @@ function validateTypeDef(Constructor, typeDef, location) {
360
366
  if (typeDef.hasOwnProperty(propName)) {
361
367
  // use a warning instead of an invariant so components
362
368
  // don't show up in prod but not in __DEV__
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) : null;
369
+ 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) : undefined;
364
370
  }
365
371
  }
366
372
  }
@@ -370,12 +376,12 @@ function validateMethodOverride(proto, name) {
370
376
 
371
377
  // Disallow overriding of base class methods unless explicitly allowed.
372
378
  if (ReactClassMixin.hasOwnProperty(name)) {
373
- 'production' !== process.env.NODE_ENV ? invariant(specPolicy === SpecPolicy.OVERRIDE_BASE, 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE);
379
+ !(specPolicy === 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) : invariant(false) : undefined;
374
380
  }
375
381
 
376
382
  // Disallow defining methods more than once unless explicitly allowed.
377
383
  if (proto.hasOwnProperty(name)) {
378
- 'production' !== process.env.NODE_ENV ? invariant(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED);
384
+ !(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === 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) : invariant(false) : undefined;
379
385
  }
380
386
  }
381
387
 
@@ -388,8 +394,8 @@ function mixSpecIntoComponent(Constructor, spec) {
388
394
  return;
389
395
  }
390
396
 
391
- 'production' !== process.env.NODE_ENV ? invariant(typeof spec !== 'function', 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(typeof spec !== 'function');
392
- 'production' !== process.env.NODE_ENV ? invariant(!ReactElement.isValidElement(spec), 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(!ReactElement.isValidElement(spec));
397
+ !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
398
+ !!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.') : invariant(false) : undefined;
393
399
 
394
400
  var proto = Constructor.prototype;
395
401
 
@@ -406,7 +412,7 @@ function mixSpecIntoComponent(Constructor, spec) {
406
412
  }
407
413
 
408
414
  if (name === MIXINS_KEY) {
409
- // We have already handled mixins in a special case above
415
+ // We have already handled mixins in a special case above.
410
416
  continue;
411
417
  }
412
418
 
@@ -435,8 +441,8 @@ function mixSpecIntoComponent(Constructor, spec) {
435
441
  if (isAlreadyDefined) {
436
442
  var specPolicy = ReactClassInterface[name];
437
443
 
438
- // These cases should already be caught by validateMethodOverride
439
- 'production' !== process.env.NODE_ENV ? invariant(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY), 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY));
444
+ // These cases should already be caught by validateMethodOverride.
445
+ !(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === 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) : invariant(false) : undefined;
440
446
 
441
447
  // For methods which are defined more than once, call the existing
442
448
  // methods before calling the new property, merging if appropriate.
@@ -447,7 +453,7 @@ function mixSpecIntoComponent(Constructor, spec) {
447
453
  }
448
454
  } else {
449
455
  proto[name] = property;
450
- if ('production' !== process.env.NODE_ENV) {
456
+ if (process.env.NODE_ENV !== 'production') {
451
457
  // Add verbose displayName to the function, which helps when looking
452
458
  // at profiling tools.
453
459
  if (typeof property === 'function' && spec.displayName) {
@@ -471,10 +477,10 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
471
477
  }
472
478
 
473
479
  var isReserved = (name in RESERVED_SPEC_KEYS);
474
- 'production' !== process.env.NODE_ENV ? invariant(!isReserved, '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(!isReserved);
480
+ !!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) : invariant(false) : undefined;
475
481
 
476
482
  var isInherited = (name in Constructor);
477
- 'production' !== process.env.NODE_ENV ? invariant(!isInherited, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name) : invariant(!isInherited);
483
+ !!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) : invariant(false) : undefined;
478
484
  Constructor[name] = property;
479
485
  }
480
486
  }
@@ -487,11 +493,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
487
493
  * @return {object} one after it has been mutated to contain everything in two.
488
494
  */
489
495
  function mergeIntoWithNoDuplicateKeys(one, two) {
490
- 'production' !== process.env.NODE_ENV ? invariant(one && two && typeof one === 'object' && typeof two === 'object', 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(one && two && typeof one === 'object' && typeof two === 'object');
496
+ !(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined;
491
497
 
492
498
  for (var key in two) {
493
499
  if (two.hasOwnProperty(key)) {
494
- 'production' !== process.env.NODE_ENV ? invariant(one[key] === undefined, '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(one[key] === undefined);
500
+ !(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) : invariant(false) : undefined;
495
501
  one[key] = two[key];
496
502
  }
497
503
  }
@@ -546,7 +552,7 @@ function createChainedFunction(one, two) {
546
552
  */
547
553
  function bindAutoBindMethod(component, method) {
548
554
  var boundMethod = method.bind(component);
549
- if ('production' !== process.env.NODE_ENV) {
555
+ if (process.env.NODE_ENV !== 'production') {
550
556
  boundMethod.__reactBoundContext = component;
551
557
  boundMethod.__reactBoundMethod = method;
552
558
  boundMethod.__reactBoundArguments = null;
@@ -562,9 +568,9 @@ function bindAutoBindMethod(component, method) {
562
568
  // ignore the value of "this" that the user is trying to use, so
563
569
  // let's warn.
564
570
  if (newThis !== component && newThis !== null) {
565
- 'production' !== process.env.NODE_ENV ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : null;
571
+ process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined;
566
572
  } else if (!args.length) {
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) : null;
573
+ 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) : undefined;
568
574
  return boundMethod;
569
575
  }
570
576
  var reboundMethod = _bind.apply(boundMethod, arguments);
@@ -592,18 +598,6 @@ function bindAutoBindMethods(component) {
592
598
  }
593
599
  }
594
600
 
595
- var typeDeprecationDescriptor = {
596
- enumerable: false,
597
- get: function () {
598
- var displayName = this.displayName || this.name || 'Component';
599
- 'production' !== process.env.NODE_ENV ? warning(false, '%s.type is deprecated. Use %s directly to access the class.', displayName, displayName) : null;
600
- Object.defineProperty(this, 'type', {
601
- value: this
602
- });
603
- return this;
604
- }
605
- };
606
-
607
601
  /**
608
602
  * Add more to the ReactClass base class. These are all legacy features and
609
603
  * therefore not already part of the modern ReactComponent.
@@ -615,9 +609,9 @@ var ReactClassMixin = {
615
609
  * type signature and the only use case for this, is to avoid that.
616
610
  */
617
611
  replaceState: function (newState, callback) {
618
- ReactUpdateQueue.enqueueReplaceState(this, newState);
612
+ this.updater.enqueueReplaceState(this, newState);
619
613
  if (callback) {
620
- ReactUpdateQueue.enqueueCallback(this, callback);
614
+ this.updater.enqueueCallback(this, callback);
621
615
  }
622
616
  },
623
617
 
@@ -628,19 +622,7 @@ var ReactClassMixin = {
628
622
  * @final
629
623
  */
630
624
  isMounted: function () {
631
- if ('production' !== process.env.NODE_ENV) {
632
- var owner = ReactCurrentOwner.current;
633
- if (owner !== 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') : null;
635
- owner._warnedAboutRefsInRender = true;
636
- }
637
- }
638
- var internalInstance = ReactInstanceMap.get(this);
639
- if (internalInstance) {
640
- return internalInstance !== ReactLifeCycle.currentlyMountingInstance;
641
- } else {
642
- return false;
643
- }
625
+ return this.updater.isMounted(this);
644
626
  },
645
627
 
646
628
  /**
@@ -653,9 +635,12 @@ var ReactClassMixin = {
653
635
  * @deprecated
654
636
  */
655
637
  setProps: function (partialProps, callback) {
656
- ReactUpdateQueue.enqueueSetProps(this, partialProps);
638
+ if (process.env.NODE_ENV !== 'production') {
639
+ warnSetProps();
640
+ }
641
+ this.updater.enqueueSetProps(this, partialProps);
657
642
  if (callback) {
658
- ReactUpdateQueue.enqueueCallback(this, callback);
643
+ this.updater.enqueueCallback(this, callback);
659
644
  }
660
645
  },
661
646
 
@@ -669,9 +654,12 @@ var ReactClassMixin = {
669
654
  * @deprecated
670
655
  */
671
656
  replaceProps: function (newProps, callback) {
672
- ReactUpdateQueue.enqueueReplaceProps(this, newProps);
657
+ if (process.env.NODE_ENV !== 'production') {
658
+ warnSetProps();
659
+ }
660
+ this.updater.enqueueReplaceProps(this, newProps);
673
661
  if (callback) {
674
- ReactUpdateQueue.enqueueCallback(this, callback);
662
+ this.updater.enqueueCallback(this, callback);
675
663
  }
676
664
  }
677
665
  };
@@ -694,12 +682,12 @@ var ReactClass = {
694
682
  * @public
695
683
  */
696
684
  createClass: function (spec) {
697
- var Constructor = function (props, context) {
685
+ var Constructor = function (props, context, updater) {
698
686
  // This constructor is overridden by mocks. The argument is used
699
687
  // by mocks to assert on what gets mounted.
700
688
 
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') : null;
689
+ if (process.env.NODE_ENV !== 'production') {
690
+ 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') : undefined;
703
691
  }
704
692
 
705
693
  // Wire up auto-binding
@@ -709,13 +697,16 @@ var ReactClass = {
709
697
 
710
698
  this.props = props;
711
699
  this.context = context;
700
+ this.refs = emptyObject;
701
+ this.updater = updater || ReactNoopUpdateQueue;
702
+
712
703
  this.state = null;
713
704
 
714
705
  // ReactClasses doesn't have constructors. Instead, they use the
715
706
  // getInitialState and componentWillMount methods for initialization.
716
707
 
717
708
  var initialState = this.getInitialState ? this.getInitialState() : null;
718
- if ('production' !== process.env.NODE_ENV) {
709
+ if (process.env.NODE_ENV !== 'production') {
719
710
  // We allow auto-mocks to proceed as if they're returning null.
720
711
  if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) {
721
712
  // This is probably bad practice. Consider warning here and
@@ -723,7 +714,7 @@ var ReactClass = {
723
714
  initialState = null;
724
715
  }
725
716
  }
726
- 'production' !== process.env.NODE_ENV ? invariant(typeof initialState === 'object' && !Array.isArray(initialState), '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(typeof initialState === 'object' && !Array.isArray(initialState));
717
+ !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined;
727
718
 
728
719
  this.state = initialState;
729
720
  };
@@ -734,12 +725,12 @@ var ReactClass = {
734
725
 
735
726
  mixSpecIntoComponent(Constructor, spec);
736
727
 
737
- // Initialize the defaultProps property after all mixins have been merged
728
+ // Initialize the defaultProps property after all mixins have been merged.
738
729
  if (Constructor.getDefaultProps) {
739
730
  Constructor.defaultProps = Constructor.getDefaultProps();
740
731
  }
741
732
 
742
- if ('production' !== process.env.NODE_ENV) {
733
+ if (process.env.NODE_ENV !== 'production') {
743
734
  // This is a tag to indicate that the use of these method names is ok,
744
735
  // since it's used with createClass. If it's not, then it's likely a
745
736
  // mistake so we'll warn you to use the static property, property
@@ -752,10 +743,11 @@ var ReactClass = {
752
743
  }
753
744
  }
754
745
 
755
- 'production' !== process.env.NODE_ENV ? invariant(Constructor.prototype.render, 'createClass(...): Class specification must implement a `render` method.') : invariant(Constructor.prototype.render);
746
+ !Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined;
756
747
 
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') : null;
748
+ if (process.env.NODE_ENV !== 'production') {
749
+ 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') : undefined;
750
+ process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : undefined;
759
751
  }
760
752
 
761
753
  // Reduce time spent doing lookups by setting these on the prototype.
@@ -765,14 +757,6 @@ var ReactClass = {
765
757
  }
766
758
  }
767
759
 
768
- // Legacy hook
769
- Constructor.type = Constructor;
770
- if ('production' !== process.env.NODE_ENV) {
771
- try {
772
- Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
773
- } catch (x) {}
774
- }
775
-
776
760
  return Constructor;
777
761
  },
778
762
 
@@ -784,6 +768,4 @@ var ReactClass = {
784
768
 
785
769
  };
786
770
 
787
- module.exports = ReactClass;
788
-
789
- // IE will fail on defineProperty (es5-shim/sham too)
771
+ module.exports = ReactClass;
@@ -11,17 +11,22 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactUpdateQueue = require("./ReactUpdateQueue");
14
+ var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
15
15
 
16
- var invariant = require("./invariant");
17
- var warning = require("./warning");
16
+ var emptyObject = require('fbjs/lib/emptyObject');
17
+ var invariant = require('fbjs/lib/invariant');
18
+ var warning = require('fbjs/lib/warning');
18
19
 
19
20
  /**
20
21
  * Base class helpers for the updating state of a component.
21
22
  */
22
- function ReactComponent(props, context) {
23
+ function ReactComponent(props, context, updater) {
23
24
  this.props = props;
24
25
  this.context = context;
26
+ this.refs = emptyObject;
27
+ // We initialize the default updater but the real one gets injected by the
28
+ // renderer.
29
+ this.updater = updater || ReactNoopUpdateQueue;
25
30
  }
26
31
 
27
32
  /**
@@ -50,13 +55,13 @@ function ReactComponent(props, context) {
50
55
  * @protected
51
56
  */
52
57
  ReactComponent.prototype.setState = function (partialState, callback) {
53
- 'production' !== process.env.NODE_ENV ? invariant(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null);
54
- if ('production' !== process.env.NODE_ENV) {
55
- 'production' !== process.env.NODE_ENV ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : null;
58
+ !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(false) : undefined;
59
+ if (process.env.NODE_ENV !== 'production') {
60
+ process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : undefined;
56
61
  }
57
- ReactUpdateQueue.enqueueSetState(this, partialState);
62
+ this.updater.enqueueSetState(this, partialState);
58
63
  if (callback) {
59
- ReactUpdateQueue.enqueueCallback(this, callback);
64
+ this.updater.enqueueCallback(this, callback);
60
65
  }
61
66
  };
62
67
 
@@ -75,9 +80,9 @@ ReactComponent.prototype.setState = function (partialState, callback) {
75
80
  * @protected
76
81
  */
77
82
  ReactComponent.prototype.forceUpdate = function (callback) {
78
- ReactUpdateQueue.enqueueForceUpdate(this);
83
+ this.updater.enqueueForceUpdate(this);
79
84
  if (callback) {
80
- ReactUpdateQueue.enqueueCallback(this, callback);
85
+ this.updater.enqueueCallback(this, callback);
81
86
  }
82
87
  };
83
88
 
@@ -86,7 +91,7 @@ ReactComponent.prototype.forceUpdate = function (callback) {
86
91
  * we would like to deprecate them, we're not going to move them over to this
87
92
  * modern base class. Instead, we define a getter that warns if it's accessed.
88
93
  */
89
- if ('production' !== process.env.NODE_ENV) {
94
+ if (process.env.NODE_ENV !== 'production') {
90
95
  var deprecatedAPIs = {
91
96
  getDOMNode: ['getDOMNode', 'Use React.findDOMNode(component) instead.'],
92
97
  isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
@@ -98,11 +103,13 @@ if ('production' !== process.env.NODE_ENV) {
98
103
  try {
99
104
  Object.defineProperty(ReactComponent.prototype, methodName, {
100
105
  get: function () {
101
- 'production' !== process.env.NODE_ENV ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : null;
106
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : undefined;
102
107
  return undefined;
103
108
  }
104
109
  });
105
- } catch (x) {}
110
+ } catch (x) {
111
+ // IE will fail on defineProperty (es5-shim/sham too)
112
+ }
106
113
  };
107
114
  for (var fnName in deprecatedAPIs) {
108
115
  if (deprecatedAPIs.hasOwnProperty(fnName)) {
@@ -111,6 +118,4 @@ if ('production' !== process.env.NODE_ENV) {
111
118
  }
112
119
  }
113
120
 
114
- module.exports = ReactComponent;
115
-
116
- // IE will fail on defineProperty (es5-shim/sham too)
121
+ module.exports = ReactComponent;