react 0.13.3 → 0.14.0-beta1

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 (189) hide show
  1. package/README.md +5 -2
  2. package/addons.js +7 -0
  3. package/dist/JSXTransformer.js +4101 -2432
  4. package/dist/react-with-addons.js +4389 -6277
  5. package/dist/react-with-addons.min.js +6 -8
  6. package/dist/react.js +4028 -5697
  7. package/dist/react.min.js +5 -6
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
  9. package/lib/BeforeInputEventPlugin.js +30 -118
  10. package/lib/CSSCore.js +12 -23
  11. package/lib/CSSProperty.js +4 -3
  12. package/lib/CSSPropertyOperations.js +14 -30
  13. package/lib/CallbackQueue.js +7 -10
  14. package/lib/ChangeEventPlugin.js +26 -88
  15. package/lib/ClientReactRootIndex.js +2 -2
  16. package/lib/DOMChildrenOperations.js +13 -33
  17. package/lib/DOMProperty.js +86 -147
  18. package/lib/DOMPropertyOperations.js +91 -67
  19. package/lib/Danger.js +19 -62
  20. package/lib/DefaultEventPluginOrder.js +2 -12
  21. package/lib/EnterLeaveEventPlugin.js +11 -33
  22. package/lib/EventConstants.js +2 -2
  23. package/lib/EventListener.js +11 -13
  24. package/lib/EventPluginHub.js +44 -47
  25. package/lib/EventPluginRegistry.js +18 -74
  26. package/lib/EventPluginUtils.js +33 -44
  27. package/lib/EventPropagators.js +23 -26
  28. package/lib/ExecutionEnvironment.js +4 -8
  29. package/lib/FallbackCompositionState.js +3 -3
  30. package/lib/HTMLDOMPropertyConfig.js +15 -20
  31. package/lib/LinkedStateMixin.js +3 -6
  32. package/lib/LinkedValueUtils.js +71 -89
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +20 -11
  35. package/lib/React.js +9 -129
  36. package/lib/ReactBrowserComponentMixin.js +9 -2
  37. package/lib/ReactBrowserEventEmitter.js +26 -82
  38. package/lib/ReactCSSTransitionGroup.js +13 -24
  39. package/lib/ReactCSSTransitionGroupChild.js +26 -28
  40. package/lib/ReactChildReconciler.js +11 -19
  41. package/lib/ReactChildren.js +24 -31
  42. package/lib/ReactClass.js +96 -267
  43. package/lib/ReactComponent.js +28 -57
  44. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  45. package/lib/ReactComponentEnvironment.js +6 -12
  46. package/lib/ReactComponentWithPureRenderMixin.js +6 -7
  47. package/lib/ReactCompositeComponent.js +115 -381
  48. package/lib/ReactCurrentOwner.js +1 -3
  49. package/lib/ReactDOM.js +4 -2
  50. package/lib/ReactDOMButton.js +16 -28
  51. package/lib/ReactDOMClient.js +90 -0
  52. package/lib/ReactDOMComponent.js +468 -156
  53. package/lib/ReactDOMIDOperations.js +25 -22
  54. package/lib/ReactDOMInput.js +79 -108
  55. package/lib/ReactDOMOption.js +58 -20
  56. package/lib/ReactDOMSelect.js +95 -83
  57. package/lib/ReactDOMSelection.js +5 -20
  58. package/lib/ReactDOMServer.js +24 -0
  59. package/lib/ReactDOMTextComponent.js +17 -18
  60. package/lib/ReactDOMTextarea.js +44 -69
  61. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  62. package/lib/ReactDefaultInjection.js +20 -76
  63. package/lib/ReactDefaultPerf.js +36 -69
  64. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  65. package/lib/ReactElement.js +26 -120
  66. package/lib/ReactElementValidator.js +56 -192
  67. package/lib/ReactEmptyComponent.js +7 -11
  68. package/lib/ReactErrorUtils.js +3 -3
  69. package/lib/ReactEventEmitterMixin.js +3 -13
  70. package/lib/ReactEventListener.js +58 -40
  71. package/lib/ReactFragment.js +33 -59
  72. package/lib/ReactInjection.js +1 -1
  73. package/lib/ReactInputSelection.js +14 -23
  74. package/lib/ReactInstanceHandles.js +29 -58
  75. package/lib/ReactInstanceMap.js +5 -5
  76. package/lib/ReactIsomorphic.js +70 -0
  77. package/lib/ReactLink.js +2 -4
  78. package/lib/ReactMarkupChecksum.js +5 -10
  79. package/lib/ReactMount.js +142 -285
  80. package/lib/ReactMultiChild.js +19 -45
  81. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  82. package/lib/ReactNativeComponent.js +6 -15
  83. package/lib/ReactNoopUpdateQueue.js +118 -0
  84. package/lib/ReactOwner.js +7 -24
  85. package/lib/ReactPerf.js +8 -12
  86. package/lib/ReactPropTransferer.js +4 -4
  87. package/lib/ReactPropTypeLocationNames.js +2 -2
  88. package/lib/ReactPropTypeLocations.js +1 -1
  89. package/lib/ReactPropTypes.js +41 -61
  90. package/lib/ReactReconcileTransaction.js +11 -36
  91. package/lib/ReactReconciler.js +14 -26
  92. package/lib/ReactRef.js +5 -8
  93. package/lib/ReactRootIndex.js +2 -2
  94. package/lib/ReactServerBatchingStrategy.js +23 -0
  95. package/lib/ReactServerRendering.js +20 -15
  96. package/lib/ReactServerRenderingTransaction.js +9 -34
  97. package/lib/ReactStateSetters.js +6 -6
  98. package/lib/ReactTestUtils.js +137 -190
  99. package/lib/ReactTransitionChildMapping.js +5 -7
  100. package/lib/ReactTransitionEvents.js +5 -5
  101. package/lib/ReactTransitionGroup.js +30 -52
  102. package/lib/ReactUpdateQueue.js +69 -107
  103. package/lib/ReactUpdates.js +26 -81
  104. package/lib/ReactWithAddons.js +5 -6
  105. package/lib/SVGDOMPropertyConfig.js +39 -4
  106. package/lib/SelectEventPlugin.js +31 -33
  107. package/lib/ServerReactRootIndex.js +2 -2
  108. package/lib/SimpleEventPlugin.js +138 -130
  109. package/lib/SyntheticClipboardEvent.js +5 -9
  110. package/lib/SyntheticCompositionEvent.js +4 -10
  111. package/lib/SyntheticDragEvent.js +3 -3
  112. package/lib/SyntheticEvent.js +14 -15
  113. package/lib/SyntheticFocusEvent.js +3 -3
  114. package/lib/SyntheticInputEvent.js +4 -10
  115. package/lib/SyntheticKeyboardEvent.js +6 -6
  116. package/lib/SyntheticMouseEvent.js +10 -16
  117. package/lib/SyntheticTouchEvent.js +3 -3
  118. package/lib/SyntheticUIEvent.js +5 -5
  119. package/lib/SyntheticWheelEvent.js +13 -17
  120. package/lib/Transaction.js +22 -28
  121. package/lib/ViewportMetrics.js +2 -2
  122. package/lib/accumulateInto.js +2 -5
  123. package/lib/adler32.js +2 -4
  124. package/lib/camelize.js +4 -2
  125. package/lib/camelizeStyleName.js +2 -2
  126. package/lib/cloneWithProps.js +6 -12
  127. package/lib/containsNode.js +29 -16
  128. package/lib/createArrayFromMixed.js +17 -16
  129. package/lib/createNodesFromMarkup.js +6 -8
  130. package/lib/dangerousStyleValue.js +2 -3
  131. package/lib/deprecated.js +47 -0
  132. package/lib/emptyFunction.js +10 -4
  133. package/lib/emptyObject.js +1 -1
  134. package/lib/escapeTextContentForBrowser.js +1 -1
  135. package/lib/findDOMNode.js +7 -27
  136. package/lib/flattenChildren.js +4 -10
  137. package/lib/focusNode.js +2 -3
  138. package/lib/forEachAccumulated.js +3 -3
  139. package/lib/getActiveElement.js +4 -2
  140. package/lib/getEventCharCode.js +2 -2
  141. package/lib/getEventKey.js +1 -1
  142. package/lib/getEventModifierState.js +1 -2
  143. package/lib/getEventTarget.js +1 -1
  144. package/lib/getIteratorFn.js +2 -4
  145. package/lib/getMarkupWrap.js +18 -40
  146. package/lib/getNodeForCharacterOffset.js +1 -1
  147. package/lib/getTextContentAccessor.js +2 -4
  148. package/lib/getUnboundedScrollPosition.js +1 -1
  149. package/lib/hyphenate.js +3 -1
  150. package/lib/hyphenateStyleName.js +2 -2
  151. package/lib/instantiateReactComponent.js +23 -43
  152. package/lib/invariant.js +8 -12
  153. package/lib/isEventSupported.js +7 -10
  154. package/lib/isNode.js +4 -6
  155. package/lib/isTextInputElement.js +3 -4
  156. package/lib/isTextNode.js +3 -1
  157. package/lib/joinClasses.js +3 -3
  158. package/lib/keyMirror.js +3 -6
  159. package/lib/keyOf.js +4 -3
  160. package/lib/mapObject.js +1 -1
  161. package/lib/memoizeStringOnly.js +2 -2
  162. package/lib/onlyChild.js +2 -5
  163. package/lib/performance.js +2 -5
  164. package/lib/performanceNow.js +3 -1
  165. package/lib/quoteAttributeValueForBrowser.js +1 -1
  166. package/lib/renderSubtreeIntoContainer.js +16 -0
  167. package/lib/setInnerHTML.js +11 -8
  168. package/lib/setTextContent.js +3 -3
  169. package/lib/shallowCompare.js +24 -0
  170. package/lib/shallowEqual.js +17 -11
  171. package/lib/shouldUpdateReactComponent.js +3 -64
  172. package/lib/toArray.js +8 -19
  173. package/lib/traverseAllChildren.js +23 -90
  174. package/lib/update.js +25 -85
  175. package/lib/validateDOMNesting.js +363 -0
  176. package/lib/warning.js +15 -17
  177. package/package.json +3 -3
  178. package/react.js +53 -1
  179. package/lib/LocalEventTrapMixin.js +0 -53
  180. package/lib/MobileSafariClickEventPlugin.js +0 -56
  181. package/lib/ReactContext.js +0 -74
  182. package/lib/ReactDOMForm.js +0 -47
  183. package/lib/ReactDOMIframe.js +0 -43
  184. package/lib/ReactDOMImg.js +0 -44
  185. package/lib/ReactLifeCycle.js +0 -35
  186. package/lib/ReactPutListenerQueue.js +0 -54
  187. package/lib/createFullPageComponent.js +0 -58
  188. package/lib/cx.js +0 -52
  189. package/lib/getReactRootElementInContainer.js +0 -33
@@ -29,34 +29,34 @@ var NO_EVENT_TIMEOUT = 5000;
29
29
 
30
30
  var noEventListener = null;
31
31
 
32
-
33
- if ("production" !== process.env.NODE_ENV) {
34
- noEventListener = function() {
35
- ("production" !== process.env.NODE_ENV ? warning(
36
- false,
37
- 'transition(): tried to perform an animation without ' +
38
- 'an animationend or transitionend event after timeout (' +
39
- '%sms). You should either disable this ' +
40
- 'transition in JS or add a CSS animation/transition.',
41
- NO_EVENT_TIMEOUT
42
- ) : null);
32
+ if ('production' !== process.env.NODE_ENV) {
33
+ noEventListener = function () {
34
+ 'production' !== process.env.NODE_ENV ? warning(false, 'transition(): tried to perform an animation without ' + 'an animationend or transitionend event after timeout (' + '%sms). You should either disable this ' + 'transition in JS or add a CSS animation/transition.', NO_EVENT_TIMEOUT) : undefined;
43
35
  };
44
36
  }
45
37
 
46
38
  var ReactCSSTransitionGroupChild = React.createClass({
47
39
  displayName: 'ReactCSSTransitionGroupChild',
48
40
 
49
- transition: function(animationType, finishCallback) {
50
- var node = this.getDOMNode();
41
+ transition: function (animationType, finishCallback) {
42
+ var node = React.findDOMNode(this);
43
+
44
+ if (!node) {
45
+ if (finishCallback) {
46
+ finishCallback();
47
+ }
48
+ return;
49
+ }
50
+
51
51
  var className = this.props.name + '-' + animationType;
52
52
  var activeClassName = className + '-active';
53
53
  var noEventTimeout = null;
54
54
 
55
- var endListener = function(e) {
55
+ var endListener = function (e) {
56
56
  if (e && e.target !== node) {
57
57
  return;
58
58
  }
59
- if ("production" !== process.env.NODE_ENV) {
59
+ if ('production' !== process.env.NODE_ENV) {
60
60
  clearTimeout(noEventTimeout);
61
61
  }
62
62
 
@@ -79,12 +79,12 @@ var ReactCSSTransitionGroupChild = React.createClass({
79
79
  // Need to do this to actually trigger a transition.
80
80
  this.queueClass(activeClassName);
81
81
 
82
- if ("production" !== process.env.NODE_ENV) {
82
+ if ('production' !== process.env.NODE_ENV) {
83
83
  noEventTimeout = setTimeout(noEventListener, NO_EVENT_TIMEOUT);
84
84
  }
85
85
  },
86
86
 
87
- queueClass: function(className) {
87
+ queueClass: function (className) {
88
88
  this.classNameQueue.push(className);
89
89
 
90
90
  if (!this.timeout) {
@@ -92,27 +92,25 @@ var ReactCSSTransitionGroupChild = React.createClass({
92
92
  }
93
93
  },
94
94
 
95
- flushClassNameQueue: function() {
95
+ flushClassNameQueue: function () {
96
96
  if (this.isMounted()) {
97
- this.classNameQueue.forEach(
98
- CSSCore.addClass.bind(CSSCore, this.getDOMNode())
99
- );
97
+ this.classNameQueue.forEach(CSSCore.addClass.bind(CSSCore, React.findDOMNode(this)));
100
98
  }
101
99
  this.classNameQueue.length = 0;
102
100
  this.timeout = null;
103
101
  },
104
102
 
105
- componentWillMount: function() {
103
+ componentWillMount: function () {
106
104
  this.classNameQueue = [];
107
105
  },
108
106
 
109
- componentWillUnmount: function() {
107
+ componentWillUnmount: function () {
110
108
  if (this.timeout) {
111
109
  clearTimeout(this.timeout);
112
110
  }
113
111
  },
114
112
 
115
- componentWillAppear: function(done) {
113
+ componentWillAppear: function (done) {
116
114
  if (this.props.appear) {
117
115
  this.transition('appear', done);
118
116
  } else {
@@ -120,7 +118,7 @@ var ReactCSSTransitionGroupChild = React.createClass({
120
118
  }
121
119
  },
122
120
 
123
- componentWillEnter: function(done) {
121
+ componentWillEnter: function (done) {
124
122
  if (this.props.enter) {
125
123
  this.transition('enter', done);
126
124
  } else {
@@ -128,7 +126,7 @@ var ReactCSSTransitionGroupChild = React.createClass({
128
126
  }
129
127
  },
130
128
 
131
- componentWillLeave: function(done) {
129
+ componentWillLeave: function (done) {
132
130
  if (this.props.leave) {
133
131
  this.transition('leave', done);
134
132
  } else {
@@ -136,9 +134,9 @@ var ReactCSSTransitionGroupChild = React.createClass({
136
134
  }
137
135
  },
138
136
 
139
- render: function() {
137
+ render: function () {
140
138
  return onlyChild(this.props.children);
141
139
  }
142
140
  });
143
141
 
144
- module.exports = ReactCSSTransitionGroupChild;
142
+ module.exports = ReactCSSTransitionGroupChild;
@@ -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
  /**
@@ -47,7 +47,7 @@ function forEachSingleChild(traverseContext, child, name, i) {
47
47
  * leaf child.
48
48
  *
49
49
  * @param {?*} children Children tree container.
50
- * @param {function(*, int)} forEachFunc.
50
+ * @param {function(*, int)} forEachFunc
51
51
  * @param {*} forEachContext Context for forEachContext.
52
52
  */
53
53
  function forEachChildren(children, forEachFunc, forEachContext) {
@@ -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
  }
@@ -109,8 +102,8 @@ function mapSingleChildIntoContext(traverseContext, child, name, i) {
109
102
  * previously relying on the fact that we guarded against null children.
110
103
  *
111
104
  * @param {?*} children Children tree container.
112
- * @param {function(*, int)} mapFunction.
113
- * @param {*} mapContext Context for mapFunction.
105
+ * @param {function(*, int)} func The map function.
106
+ * @param {*} context Context for mapFunction.
114
107
  * @return {object} Object containing the ordered map of results.
115
108
  */
116
109
  function mapChildren(children, func, context) {
@@ -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
@@ -12,22 +12,20 @@
12
12
  'use strict';
13
13
 
14
14
  var ReactComponent = require("./ReactComponent");
15
- var ReactCurrentOwner = require("./ReactCurrentOwner");
16
15
  var ReactElement = require("./ReactElement");
17
16
  var ReactErrorUtils = require("./ReactErrorUtils");
18
- var ReactInstanceMap = require("./ReactInstanceMap");
19
- var ReactLifeCycle = require("./ReactLifeCycle");
20
17
  var ReactPropTypeLocations = require("./ReactPropTypeLocations");
21
18
  var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
22
- var ReactUpdateQueue = require("./ReactUpdateQueue");
19
+ var ReactNoopUpdateQueue = require("./ReactNoopUpdateQueue");
23
20
 
24
21
  var assign = require("./Object.assign");
22
+ var emptyObject = require("./emptyObject");
25
23
  var invariant = require("./invariant");
26
24
  var keyMirror = require("./keyMirror");
27
25
  var keyOf = require("./keyOf");
28
26
  var warning = require("./warning");
29
27
 
30
- var MIXINS_KEY = keyOf({mixins: null});
28
+ var MIXINS_KEY = keyOf({ mixins: null });
31
29
 
32
30
  /**
33
31
  * Policies that describe methods in `ReactClassInterface`.
@@ -54,9 +52,16 @@ var SpecPolicy = keyMirror({
54
52
  DEFINE_MANY_MERGED: null
55
53
  });
56
54
 
57
-
58
55
  var injectedMixins = [];
59
56
 
57
+ var warnedSetProps = false;
58
+ function warnSetProps() {
59
+ if (!warnedSetProps) {
60
+ warnedSetProps = true;
61
+ 'production' !== process.env.NODE_ENV ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call React.render again at the top level.') : undefined;
62
+ }
63
+ }
64
+
60
65
  /**
61
66
  * Composite components are higher-level components that compose other composite
62
67
  * or native components.
@@ -74,7 +79,7 @@ var injectedMixins = [];
74
79
  * The class specification supports a specific protocol of methods that have
75
80
  * special meaning (e.g. `render`). See `ReactClassInterface` for
76
81
  * more the comprehensive protocol. Any other properties and methods in the
77
- * class specification will available on the prototype.
82
+ * class specification will be available on the prototype.
78
83
  *
79
84
  * @interface ReactClassInterface
80
85
  * @internal
@@ -176,8 +181,6 @@ var ReactClassInterface = {
176
181
  */
177
182
  render: SpecPolicy.DEFINE_ONCE,
178
183
 
179
-
180
-
181
184
  // ==== Delegate methods ====
182
185
 
183
186
  /**
@@ -288,8 +291,6 @@ var ReactClassInterface = {
288
291
  */
289
292
  componentWillUnmount: SpecPolicy.DEFINE_MANY,
290
293
 
291
-
292
-
293
294
  // ==== Advanced methods ====
294
295
 
295
296
  /**
@@ -316,73 +317,46 @@ var ReactClassInterface = {
316
317
  * which all other static methods are defined.
317
318
  */
318
319
  var RESERVED_SPEC_KEYS = {
319
- displayName: function(Constructor, displayName) {
320
+ displayName: function (Constructor, displayName) {
320
321
  Constructor.displayName = displayName;
321
322
  },
322
- mixins: function(Constructor, mixins) {
323
+ mixins: function (Constructor, mixins) {
323
324
  if (mixins) {
324
325
  for (var i = 0; i < mixins.length; i++) {
325
326
  mixSpecIntoComponent(Constructor, mixins[i]);
326
327
  }
327
328
  }
328
329
  },
329
- childContextTypes: function(Constructor, childContextTypes) {
330
- if ("production" !== process.env.NODE_ENV) {
331
- validateTypeDef(
332
- Constructor,
333
- childContextTypes,
334
- ReactPropTypeLocations.childContext
335
- );
330
+ childContextTypes: function (Constructor, childContextTypes) {
331
+ if ('production' !== process.env.NODE_ENV) {
332
+ validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
336
333
  }
337
- Constructor.childContextTypes = assign(
338
- {},
339
- Constructor.childContextTypes,
340
- childContextTypes
341
- );
334
+ Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes);
342
335
  },
343
- contextTypes: function(Constructor, contextTypes) {
344
- if ("production" !== process.env.NODE_ENV) {
345
- validateTypeDef(
346
- Constructor,
347
- contextTypes,
348
- ReactPropTypeLocations.context
349
- );
336
+ contextTypes: function (Constructor, contextTypes) {
337
+ if ('production' !== process.env.NODE_ENV) {
338
+ validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
350
339
  }
351
- Constructor.contextTypes = assign(
352
- {},
353
- Constructor.contextTypes,
354
- contextTypes
355
- );
340
+ Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes);
356
341
  },
357
342
  /**
358
343
  * Special case getDefaultProps which should move into statics but requires
359
344
  * automatic merging.
360
345
  */
361
- getDefaultProps: function(Constructor, getDefaultProps) {
346
+ getDefaultProps: function (Constructor, getDefaultProps) {
362
347
  if (Constructor.getDefaultProps) {
363
- Constructor.getDefaultProps = createMergedResultFunction(
364
- Constructor.getDefaultProps,
365
- getDefaultProps
366
- );
348
+ Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
367
349
  } else {
368
350
  Constructor.getDefaultProps = getDefaultProps;
369
351
  }
370
352
  },
371
- propTypes: function(Constructor, propTypes) {
372
- if ("production" !== process.env.NODE_ENV) {
373
- validateTypeDef(
374
- Constructor,
375
- propTypes,
376
- ReactPropTypeLocations.prop
377
- );
353
+ propTypes: function (Constructor, propTypes) {
354
+ if ('production' !== process.env.NODE_ENV) {
355
+ validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
378
356
  }
379
- Constructor.propTypes = assign(
380
- {},
381
- Constructor.propTypes,
382
- propTypes
383
- );
357
+ Constructor.propTypes = assign({}, Constructor.propTypes, propTypes);
384
358
  },
385
- statics: function(Constructor, statics) {
359
+ statics: function (Constructor, statics) {
386
360
  mixStaticSpecIntoComponent(Constructor, statics);
387
361
  }
388
362
  };
@@ -392,45 +366,22 @@ function validateTypeDef(Constructor, typeDef, location) {
392
366
  if (typeDef.hasOwnProperty(propName)) {
393
367
  // use a warning instead of an invariant so components
394
368
  // 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);
369
+ '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
370
  }
404
371
  }
405
372
  }
406
373
 
407
374
  function validateMethodOverride(proto, name) {
408
- var specPolicy = ReactClassInterface.hasOwnProperty(name) ?
409
- ReactClassInterface[name] :
410
- null;
375
+ var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
411
376
 
412
377
  // Disallow overriding of base class methods unless explicitly allowed.
413
378
  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));
379
+ !(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
380
  }
422
381
 
423
382
  // Disallow defining methods more than once unless explicitly allowed.
424
383
  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));
384
+ !(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
385
  }
435
386
  }
436
387
 
@@ -443,16 +394,8 @@ function mixSpecIntoComponent(Constructor, spec) {
443
394
  return;
444
395
  }
445
396
 
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)));
397
+ !(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;
398
+ !!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
399
 
457
400
  var proto = Constructor.prototype;
458
401
 
@@ -469,7 +412,7 @@ function mixSpecIntoComponent(Constructor, spec) {
469
412
  }
470
413
 
471
414
  if (name === MIXINS_KEY) {
472
- // We have already handled mixins in a special case above
415
+ // We have already handled mixins in a special case above.
473
416
  continue;
474
417
  }
475
418
 
@@ -483,16 +426,10 @@ function mixSpecIntoComponent(Constructor, spec) {
483
426
  // The following member methods should not be automatically bound:
484
427
  // 1. Expected ReactClass methods (in the "interface").
485
428
  // 2. Overridden methods (that were mixed in).
486
- var isReactClassMethod =
487
- ReactClassInterface.hasOwnProperty(name);
429
+ var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
488
430
  var isAlreadyDefined = proto.hasOwnProperty(name);
489
- var markedDontBind = property && property.__reactDontBind;
490
431
  var isFunction = typeof property === 'function';
491
- var shouldAutoBind =
492
- isFunction &&
493
- !isReactClassMethod &&
494
- !isAlreadyDefined &&
495
- !markedDontBind;
432
+ var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined;
496
433
 
497
434
  if (shouldAutoBind) {
498
435
  if (!proto.__reactAutoBindMap) {
@@ -504,18 +441,8 @@ function mixSpecIntoComponent(Constructor, spec) {
504
441
  if (isAlreadyDefined) {
505
442
  var specPolicy = ReactClassInterface[name];
506
443
 
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
- )));
444
+ // These cases should already be caught by validateMethodOverride.
445
+ !(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
446
 
520
447
  // For methods which are defined more than once, call the existing
521
448
  // methods before calling the new property, merging if appropriate.
@@ -526,7 +453,7 @@ function mixSpecIntoComponent(Constructor, spec) {
526
453
  }
527
454
  } else {
528
455
  proto[name] = property;
529
- if ("production" !== process.env.NODE_ENV) {
456
+ if ('production' !== process.env.NODE_ENV) {
530
457
  // Add verbose displayName to the function, which helps when looking
531
458
  // at profiling tools.
532
459
  if (typeof property === 'function' && spec.displayName) {
@@ -549,24 +476,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
549
476
  continue;
550
477
  }
551
478
 
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));
479
+ var isReserved = (name in RESERVED_SPEC_KEYS);
480
+ !!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;
481
+
482
+ var isInherited = (name in Constructor);
483
+ !!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
484
  Constructor[name] = property;
571
485
  }
572
486
  }
@@ -579,22 +493,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
579
493
  * @return {object} one after it has been mutated to contain everything in two.
580
494
  */
581
495
  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'));
496
+ !(one && two && typeof one === 'object' && typeof two === 'object') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined;
586
497
 
587
498
  for (var key in two) {
588
499
  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));
500
+ !(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
501
  one[key] = two[key];
599
502
  }
600
503
  }
@@ -649,32 +552,25 @@ function createChainedFunction(one, two) {
649
552
  */
650
553
  function bindAutoBindMethod(component, method) {
651
554
  var boundMethod = method.bind(component);
652
- if ("production" !== process.env.NODE_ENV) {
555
+ if ('production' !== process.env.NODE_ENV) {
653
556
  boundMethod.__reactBoundContext = component;
654
557
  boundMethod.__reactBoundMethod = method;
655
558
  boundMethod.__reactBoundArguments = null;
656
559
  var componentName = component.constructor.displayName;
657
560
  var _bind = boundMethod.bind;
658
561
  /* 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]);
562
+ boundMethod.bind = function (newThis) {
563
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
564
+ args[_key - 1] = arguments[_key];
565
+ }
566
+
660
567
  // User is trying to bind() an autobound method; we effectively will
661
568
  // ignore the value of "this" that the user is trying to use, so
662
569
  // let's warn.
663
570
  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);
571
+ 'production' !== process.env.NODE_ENV ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined;
670
572
  } 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);
573
+ '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
574
  return boundMethod;
679
575
  }
680
576
  var reboundMethod = _bind.apply(boundMethod, arguments);
@@ -697,34 +593,11 @@ function bindAutoBindMethods(component) {
697
593
  for (var autoBindKey in component.__reactAutoBindMap) {
698
594
  if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
699
595
  var method = component.__reactAutoBindMap[autoBindKey];
700
- component[autoBindKey] = bindAutoBindMethod(
701
- component,
702
- ReactErrorUtils.guard(
703
- method,
704
- component.constructor.displayName + '.' + autoBindKey
705
- )
706
- );
596
+ component[autoBindKey] = bindAutoBindMethod(component, ReactErrorUtils.guard(method, component.constructor.displayName + '.' + autoBindKey));
707
597
  }
708
598
  }
709
599
  }
710
600
 
711
- var typeDeprecationDescriptor = {
712
- enumerable: false,
713
- get: function() {
714
- 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);
721
- Object.defineProperty(this, 'type', {
722
- value: this
723
- });
724
- return this;
725
- }
726
- };
727
-
728
601
  /**
729
602
  * Add more to the ReactClass base class. These are all legacy features and
730
603
  * therefore not already part of the modern ReactComponent.
@@ -735,10 +608,10 @@ var ReactClassMixin = {
735
608
  * TODO: This will be deprecated because state should always keep a consistent
736
609
  * type signature and the only use case for this, is to avoid that.
737
610
  */
738
- replaceState: function(newState, callback) {
739
- ReactUpdateQueue.enqueueReplaceState(this, newState);
611
+ replaceState: function (newState, callback) {
612
+ this.updater.enqueueReplaceState(this, newState);
740
613
  if (callback) {
741
- ReactUpdateQueue.enqueueCallback(this, callback);
614
+ this.updater.enqueueCallback(this, callback);
742
615
  }
743
616
  },
744
617
 
@@ -748,27 +621,8 @@ var ReactClassMixin = {
748
621
  * @protected
749
622
  * @final
750
623
  */
751
- isMounted: function() {
752
- if ("production" !== process.env.NODE_ENV) {
753
- var owner = ReactCurrentOwner.current;
754
- 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);
764
- owner._warnedAboutRefsInRender = true;
765
- }
766
- }
767
- var internalInstance = ReactInstanceMap.get(this);
768
- return (
769
- internalInstance &&
770
- internalInstance !== ReactLifeCycle.currentlyMountingInstance
771
- );
624
+ isMounted: function () {
625
+ return this.updater.isMounted(this);
772
626
  },
773
627
 
774
628
  /**
@@ -780,10 +634,13 @@ var ReactClassMixin = {
780
634
  * @public
781
635
  * @deprecated
782
636
  */
783
- setProps: function(partialProps, callback) {
784
- ReactUpdateQueue.enqueueSetProps(this, partialProps);
637
+ setProps: function (partialProps, callback) {
638
+ if ('production' !== process.env.NODE_ENV) {
639
+ warnSetProps();
640
+ }
641
+ this.updater.enqueueSetProps(this, partialProps);
785
642
  if (callback) {
786
- ReactUpdateQueue.enqueueCallback(this, callback);
643
+ this.updater.enqueueCallback(this, callback);
787
644
  }
788
645
  },
789
646
 
@@ -796,20 +653,19 @@ var ReactClassMixin = {
796
653
  * @public
797
654
  * @deprecated
798
655
  */
799
- replaceProps: function(newProps, callback) {
800
- ReactUpdateQueue.enqueueReplaceProps(this, newProps);
656
+ replaceProps: function (newProps, callback) {
657
+ if ('production' !== process.env.NODE_ENV) {
658
+ warnSetProps();
659
+ }
660
+ this.updater.enqueueReplaceProps(this, newProps);
801
661
  if (callback) {
802
- ReactUpdateQueue.enqueueCallback(this, callback);
662
+ this.updater.enqueueCallback(this, callback);
803
663
  }
804
664
  }
805
665
  };
806
666
 
807
- var ReactClassComponent = function() {};
808
- assign(
809
- ReactClassComponent.prototype,
810
- ReactComponent.prototype,
811
- ReactClassMixin
812
- );
667
+ var ReactClassComponent = function () {};
668
+ assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
813
669
 
814
670
  /**
815
671
  * Module for creating composite components.
@@ -825,17 +681,13 @@ var ReactClass = {
825
681
  * @return {function} Component constructor function.
826
682
  * @public
827
683
  */
828
- createClass: function(spec) {
829
- var Constructor = function(props, context) {
684
+ createClass: function (spec) {
685
+ var Constructor = function (props, context, updater) {
830
686
  // This constructor is overridden by mocks. The argument is used
831
687
  // by mocks to assert on what gets mounted.
832
688
 
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: https://fb.me/react-legacyfactory'
838
- ) : null);
689
+ if ('production' !== process.env.NODE_ENV) {
690
+ '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
691
  }
840
692
 
841
693
  // Wire up auto-binding
@@ -845,44 +697,40 @@ var ReactClass = {
845
697
 
846
698
  this.props = props;
847
699
  this.context = context;
700
+ this.refs = emptyObject;
701
+ this.updater = updater || ReactNoopUpdateQueue;
702
+
848
703
  this.state = null;
849
704
 
850
705
  // ReactClasses doesn't have constructors. Instead, they use the
851
706
  // getInitialState and componentWillMount methods for initialization.
852
707
 
853
708
  var initialState = this.getInitialState ? this.getInitialState() : null;
854
- if ("production" !== process.env.NODE_ENV) {
709
+ if ('production' !== process.env.NODE_ENV) {
855
710
  // We allow auto-mocks to proceed as if they're returning null.
856
- if (typeof initialState === 'undefined' &&
857
- this.getInitialState._isMockFunction) {
711
+ if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) {
858
712
  // This is probably bad practice. Consider warning here and
859
713
  // deprecating this convenience.
860
714
  initialState = null;
861
715
  }
862
716
  }
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)));
717
+ !(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
718
 
869
719
  this.state = initialState;
870
720
  };
871
721
  Constructor.prototype = new ReactClassComponent();
872
722
  Constructor.prototype.constructor = Constructor;
873
723
 
874
- injectedMixins.forEach(
875
- mixSpecIntoComponent.bind(null, Constructor)
876
- );
724
+ injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
877
725
 
878
726
  mixSpecIntoComponent(Constructor, spec);
879
727
 
880
- // Initialize the defaultProps property after all mixins have been merged
728
+ // Initialize the defaultProps property after all mixins have been merged.
881
729
  if (Constructor.getDefaultProps) {
882
730
  Constructor.defaultProps = Constructor.getDefaultProps();
883
731
  }
884
732
 
885
- if ("production" !== process.env.NODE_ENV) {
733
+ if ('production' !== process.env.NODE_ENV) {
886
734
  // This is a tag to indicate that the use of these method names is ok,
887
735
  // since it's used with createClass. If it's not, then it's likely a
888
736
  // mistake so we'll warn you to use the static property, property
@@ -895,20 +743,11 @@ var ReactClass = {
895
743
  }
896
744
  }
897
745
 
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);
746
+ !Constructor.prototype.render ? 'production' !== process.env.NODE_ENV ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined;
747
+
748
+ if ('production' !== process.env.NODE_ENV) {
749
+ '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;
750
+ 'production' !== process.env.NODE_ENV ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : undefined;
912
751
  }
913
752
 
914
753
  // Reduce time spent doing lookups by setting these on the prototype.
@@ -918,25 +757,15 @@ var ReactClass = {
918
757
  }
919
758
  }
920
759
 
921
- // Legacy hook
922
- Constructor.type = Constructor;
923
- if ("production" !== process.env.NODE_ENV) {
924
- try {
925
- Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
926
- } catch (x) {
927
- // IE will fail on defineProperty (es5-shim/sham too)
928
- }
929
- }
930
-
931
760
  return Constructor;
932
761
  },
933
762
 
934
763
  injection: {
935
- injectMixin: function(mixin) {
764
+ injectMixin: function (mixin) {
936
765
  injectedMixins.push(mixin);
937
766
  }
938
767
  }
939
768
 
940
769
  };
941
770
 
942
- module.exports = ReactClass;
771
+ module.exports = ReactClass;