react 0.14.0-alpha2 → 0.14.0-beta3

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 (196) hide show
  1. package/README.md +5 -2
  2. package/addons.js +6 -3
  3. package/dist/JSXTransformer.js +634 -274
  4. package/dist/react-with-addons.js +5350 -4954
  5. package/dist/react-with-addons.min.js +6 -6
  6. package/dist/react.js +4777 -4408
  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 -117
  16. package/lib/DOMPropertyOperations.js +78 -33
  17. package/lib/Danger.js +14 -14
  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 +13 -3
  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 +6 -6
  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 +9 -9
  39. package/lib/ReactClass.js +65 -83
  40. package/lib/ReactComponent.js +22 -17
  41. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  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 +378 -56
  48. package/lib/ReactDOMFactories.js +177 -0
  49. package/lib/ReactDOMIDOperations.js +23 -23
  50. package/lib/ReactDOMInput.js +83 -99
  51. package/lib/ReactDOMOption.js +25 -45
  52. package/lib/ReactDOMSelect.js +88 -98
  53. package/lib/ReactDOMSelection.js +3 -3
  54. package/lib/ReactDOMServer.js +2 -2
  55. package/lib/ReactDOMTextComponent.js +11 -11
  56. package/lib/ReactDOMTextarea.js +48 -61
  57. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  58. package/lib/ReactDefaultInjection.js +24 -71
  59. package/lib/ReactDefaultPerf.js +7 -7
  60. package/lib/ReactDefaultPerfAnalysis.js +6 -9
  61. package/lib/ReactElement.js +22 -83
  62. package/lib/ReactElementValidator.js +48 -117
  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 +11 -11
  72. package/lib/ReactLink.js +1 -1
  73. package/lib/ReactMarkupChecksum.js +6 -2
  74. package/lib/ReactMount.js +88 -88
  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 +49 -11
  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 -1
  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 -7
  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 +15 -14
  145. package/lib/update.js +13 -13
  146. package/lib/validateDOMNesting.js +14 -6
  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/ReactDOMClient.js +0 -85
  168. package/lib/ReactDOMForm.js +0 -47
  169. package/lib/ReactDOMIframe.js +0 -43
  170. package/lib/ReactDOMImg.js +0 -44
  171. package/lib/ReactLifeCycle.js +0 -35
  172. package/lib/camelize.js +0 -32
  173. package/lib/camelizeStyleName.js +0 -40
  174. package/lib/containsNode.js +0 -55
  175. package/lib/createArrayFromMixed.js +0 -85
  176. package/lib/createFullPageComponent.js +0 -51
  177. package/lib/createNodesFromMarkup.js +0 -84
  178. package/lib/emptyFunction.js +0 -38
  179. package/lib/emptyObject.js +0 -20
  180. package/lib/focusNode.js +0 -26
  181. package/lib/getActiveElement.js +0 -29
  182. package/lib/getMarkupWrap.js +0 -115
  183. package/lib/getUnboundedScrollPosition.js +0 -38
  184. package/lib/hyphenate.js +0 -33
  185. package/lib/hyphenateStyleName.js +0 -39
  186. package/lib/invariant.js +0 -49
  187. package/lib/isNode.js +0 -23
  188. package/lib/isTextNode.js +0 -25
  189. package/lib/keyMirror.js +0 -48
  190. package/lib/keyOf.js +0 -35
  191. package/lib/mapObject.js +0 -51
  192. package/lib/performance.js +0 -23
  193. package/lib/performanceNow.js +0 -28
  194. package/lib/shallowEqual.js +0 -48
  195. package/lib/toArray.js +0 -57
  196. package/lib/warning.js +0 -61
@@ -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;
@@ -11,8 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactDOMIDOperations = require("./ReactDOMIDOperations");
15
- var ReactMount = require("./ReactMount");
14
+ var ReactDOMIDOperations = require('./ReactDOMIDOperations');
15
+ var ReactMount = require('./ReactMount');
16
16
 
17
17
  /**
18
18
  * Abstracts away all functionality of the reconciler that requires knowledge of
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var invariant = require("./invariant");
14
+ var invariant = require('fbjs/lib/invariant');
15
15
 
16
16
  var injected = false;
17
17
 
@@ -38,7 +38,7 @@ var ReactComponentEnvironment = {
38
38
 
39
39
  injection: {
40
40
  injectEnvironment: function (environment) {
41
- 'production' !== process.env.NODE_ENV ? invariant(!injected, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(!injected);
41
+ !!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : undefined;
42
42
  ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
43
43
  ReactComponentEnvironment.replaceNodeWithMarkupByID = environment.replaceNodeWithMarkupByID;
44
44
  ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
@@ -6,12 +6,12 @@
6
6
  * LICENSE file in the root directory of this source tree. An additional grant
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
- * @providesModule ReactComponentWithPureRenderMixin
10
- */
9
+ * @providesModule ReactComponentWithPureRenderMixin
10
+ */
11
11
 
12
12
  'use strict';
13
13
 
14
- var shallowCompare = require("./shallowCompare");
14
+ var shallowCompare = require('./shallowCompare');
15
15
 
16
16
  /**
17
17
  * If your React component's render function is "pure", e.g. it will render the
@@ -11,25 +11,21 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactComponentEnvironment = require("./ReactComponentEnvironment");
15
- var ReactContext = require("./ReactContext");
16
- var ReactCurrentOwner = require("./ReactCurrentOwner");
17
- var ReactElement = require("./ReactElement");
18
- var ReactElementValidator = require("./ReactElementValidator");
19
- var ReactInstanceMap = require("./ReactInstanceMap");
20
- var ReactLifeCycle = require("./ReactLifeCycle");
21
- var ReactNativeComponent = require("./ReactNativeComponent");
22
- var ReactPerf = require("./ReactPerf");
23
- var ReactPropTypeLocations = require("./ReactPropTypeLocations");
24
- var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
25
- var ReactReconciler = require("./ReactReconciler");
26
- var ReactUpdates = require("./ReactUpdates");
27
-
28
- var assign = require("./Object.assign");
29
- var emptyObject = require("./emptyObject");
30
- var invariant = require("./invariant");
31
- var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
32
- var warning = require("./warning");
14
+ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
15
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
16
+ var ReactElement = require('./ReactElement');
17
+ var ReactInstanceMap = require('./ReactInstanceMap');
18
+ var ReactPerf = require('./ReactPerf');
19
+ var ReactPropTypeLocations = require('./ReactPropTypeLocations');
20
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
21
+ var ReactReconciler = require('./ReactReconciler');
22
+ var ReactUpdateQueue = require('./ReactUpdateQueue');
23
+
24
+ var assign = require('./Object.assign');
25
+ var emptyObject = require('fbjs/lib/emptyObject');
26
+ var invariant = require('fbjs/lib/invariant');
27
+ var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
28
+ var warning = require('fbjs/lib/warning');
33
29
 
34
30
  function getDeclarationErrorAddendum(component) {
35
31
  var owner = component._currentElement._owner || null;
@@ -104,7 +100,7 @@ var ReactCompositeComponentMixin = {
104
100
 
105
101
  this._context = null;
106
102
  this._mountOrder = 0;
107
- this._isTopLevel = false;
103
+ this._topLevelWrapper = null;
108
104
 
109
105
  // See ReactUpdates and ReactUpdateQueue.
110
106
  this._pendingCallbacks = null;
@@ -127,15 +123,15 @@ var ReactCompositeComponentMixin = {
127
123
  var publicProps = this._processProps(this._currentElement.props);
128
124
  var publicContext = this._processContext(context);
129
125
 
130
- var Component = ReactNativeComponent.getComponentClassForElement(this._currentElement);
126
+ var Component = this._currentElement.type;
131
127
 
132
128
  // Initialize the public class
133
- var inst = new Component(publicProps, publicContext);
129
+ var inst = new Component(publicProps, publicContext, ReactUpdateQueue);
134
130
 
135
- if ('production' !== process.env.NODE_ENV) {
131
+ if (process.env.NODE_ENV !== 'production') {
136
132
  // This will throw later in _renderValidatedComponent, but add an early
137
133
  // warning now to help debugging
138
- 'production' !== process.env.NODE_ENV ? warning(inst.render != null, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render` in your ' + 'component or you may have accidentally tried to render an element ' + 'whose type is a function that isn\'t a React component.', Component.displayName || Component.name || 'Component') : null;
134
+ process.env.NODE_ENV !== 'production' ? warning(inst.render != null, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render` in your ' + 'component or you may have accidentally tried to render an element ' + 'whose type is a function that isn\'t a React component.', Component.displayName || Component.name || 'Component') : undefined;
139
135
  }
140
136
 
141
137
  // These should be set up in the constructor, but as a convenience for
@@ -143,54 +139,48 @@ var ReactCompositeComponentMixin = {
143
139
  inst.props = publicProps;
144
140
  inst.context = publicContext;
145
141
  inst.refs = emptyObject;
142
+ inst.updater = ReactUpdateQueue;
146
143
 
147
144
  this._instance = inst;
148
145
 
149
146
  // Store a reference from the instance back to the internal representation
150
147
  ReactInstanceMap.set(inst, this);
151
148
 
152
- if ('production' !== process.env.NODE_ENV) {
149
+ if (process.env.NODE_ENV !== 'production') {
153
150
  // Since plain JS classes are defined without any special initialization
154
151
  // logic, we can not catch common errors early. Therefore, we have to
155
152
  // catch them here, at initialization time, instead.
156
- 'production' !== process.env.NODE_ENV ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : null;
157
- 'production' !== process.env.NODE_ENV ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : null;
158
- 'production' !== process.env.NODE_ENV ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : null;
159
- 'production' !== process.env.NODE_ENV ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : null;
160
- 'production' !== process.env.NODE_ENV ? warning(typeof inst.componentShouldUpdate !== 'function', '%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.', this.getName() || 'A component') : null;
153
+ process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : undefined;
154
+ process.env.NODE_ENV !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : undefined;
155
+ process.env.NODE_ENV !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : undefined;
156
+ process.env.NODE_ENV !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : undefined;
157
+ process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentShouldUpdate !== 'function', '%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.', this.getName() || 'A component') : undefined;
158
+ process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component') : undefined;
159
+ process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : undefined;
161
160
  }
162
161
 
163
162
  var initialState = inst.state;
164
163
  if (initialState === undefined) {
165
164
  inst.state = initialState = null;
166
165
  }
167
- 'production' !== process.env.NODE_ENV ? invariant(typeof initialState === 'object' && !Array.isArray(initialState), '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(typeof initialState === 'object' && !Array.isArray(initialState));
166
+ !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
168
167
 
169
168
  this._pendingStateQueue = null;
170
169
  this._pendingReplaceState = false;
171
170
  this._pendingForceUpdate = false;
172
171
 
173
- var renderedElement;
174
-
175
- var previouslyMounting = ReactLifeCycle.currentlyMountingInstance;
176
- ReactLifeCycle.currentlyMountingInstance = this;
177
- try {
178
- if (inst.componentWillMount) {
179
- inst.componentWillMount();
180
- // When mounting, calls to `setState` by `componentWillMount` will set
181
- // `this._pendingStateQueue` without triggering a re-render.
182
- if (this._pendingStateQueue) {
183
- inst.state = this._processPendingState(inst.props, inst.context);
184
- }
172
+ if (inst.componentWillMount) {
173
+ inst.componentWillMount();
174
+ // When mounting, calls to `setState` by `componentWillMount` will set
175
+ // `this._pendingStateQueue` without triggering a re-render.
176
+ if (this._pendingStateQueue) {
177
+ inst.state = this._processPendingState(inst.props, inst.context);
185
178
  }
186
-
187
- renderedElement = this._renderValidatedComponent();
188
- } finally {
189
- ReactLifeCycle.currentlyMountingInstance = previouslyMounting;
190
179
  }
191
180
 
192
- this._renderedComponent = this._instantiateReactComponent(renderedElement, this._currentElement.type // The wrapping type
193
- );
181
+ var renderedElement = this._renderValidatedComponent();
182
+
183
+ this._renderedComponent = this._instantiateReactComponent(renderedElement);
194
184
 
195
185
  var markup = ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, this._processChildContext(context));
196
186
  if (inst.componentDidMount) {
@@ -210,19 +200,15 @@ var ReactCompositeComponentMixin = {
210
200
  var inst = this._instance;
211
201
 
212
202
  if (inst.componentWillUnmount) {
213
- var previouslyUnmounting = ReactLifeCycle.currentlyUnmountingInstance;
214
- ReactLifeCycle.currentlyUnmountingInstance = this;
215
- try {
216
- inst.componentWillUnmount();
217
- } finally {
218
- ReactLifeCycle.currentlyUnmountingInstance = previouslyUnmounting;
219
- }
203
+ inst.componentWillUnmount();
220
204
  }
221
205
 
222
206
  ReactReconciler.unmountComponent(this._renderedComponent);
223
207
  this._renderedComponent = null;
224
208
 
225
209
  // Reset pending fields
210
+ // Even if this component is scheduled for another update in ReactUpdates,
211
+ // it would still be ignored because these fields are reset.
226
212
  this._pendingStateQueue = null;
227
213
  this._pendingReplaceState = false;
228
214
  this._pendingForceUpdate = false;
@@ -233,6 +219,7 @@ var ReactCompositeComponentMixin = {
233
219
  // longer accessible.
234
220
  this._context = null;
235
221
  this._rootNodeID = null;
222
+ this._topLevelWrapper = null;
236
223
 
237
224
  // Delete the reference from the instance to this internal representation
238
225
  // which allow the internals to be properly cleaned up even if the user
@@ -246,22 +233,6 @@ var ReactCompositeComponentMixin = {
246
233
  // TODO: inst.context = null;
247
234
  },
248
235
 
249
- /**
250
- * Schedule a partial update to the props. Only used for internal testing.
251
- *
252
- * @param {object} partialProps Subset of the next props.
253
- * @param {?function} callback Called after props are updated.
254
- * @final
255
- * @internal
256
- */
257
- _setPropsInternal: function (partialProps, callback) {
258
- // This is a deoptimized path. We optimize for always having an element.
259
- // This creates an extra internal element.
260
- var element = this._pendingElement || this._currentElement;
261
- this._pendingElement = ReactElement.cloneAndReplaceProps(element, assign({}, element.props, partialProps));
262
- ReactUpdates.enqueueUpdate(this, callback);
263
- },
264
-
265
236
  /**
266
237
  * Filters the context object to only contain keys specified in
267
238
  * `contextTypes`
@@ -272,12 +243,8 @@ var ReactCompositeComponentMixin = {
272
243
  */
273
244
  _maskContext: function (context) {
274
245
  var maskedContext = null;
275
- // This really should be getting the component class for the element,
276
- // but we know that we're not going to need it for built-ins.
277
- if (typeof this._currentElement.type === 'string') {
278
- return emptyObject;
279
- }
280
- var contextTypes = this._currentElement.type.contextTypes;
246
+ var Component = this._currentElement.type;
247
+ var contextTypes = Component.contextTypes;
281
248
  if (!contextTypes) {
282
249
  return emptyObject;
283
250
  }
@@ -298,8 +265,8 @@ var ReactCompositeComponentMixin = {
298
265
  */
299
266
  _processContext: function (context) {
300
267
  var maskedContext = this._maskContext(context);
301
- if ('production' !== process.env.NODE_ENV) {
302
- var Component = ReactNativeComponent.getComponentClassForElement(this._currentElement);
268
+ if (process.env.NODE_ENV !== 'production') {
269
+ var Component = this._currentElement.type;
303
270
  if (Component.contextTypes) {
304
271
  this._checkPropTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
305
272
  }
@@ -313,15 +280,16 @@ var ReactCompositeComponentMixin = {
313
280
  * @private
314
281
  */
315
282
  _processChildContext: function (currentContext) {
283
+ var Component = this._currentElement.type;
316
284
  var inst = this._instance;
317
285
  var childContext = inst.getChildContext && inst.getChildContext();
318
286
  if (childContext) {
319
- 'production' !== process.env.NODE_ENV ? invariant(typeof inst.constructor.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(typeof inst.constructor.childContextTypes === 'object');
320
- if ('production' !== process.env.NODE_ENV) {
321
- this._checkPropTypes(inst.constructor.childContextTypes, childContext, ReactPropTypeLocations.childContext);
287
+ !(typeof Component.childContextTypes === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
288
+ if (process.env.NODE_ENV !== 'production') {
289
+ this._checkPropTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
322
290
  }
323
291
  for (var name in childContext) {
324
- 'production' !== process.env.NODE_ENV ? invariant(name in inst.constructor.childContextTypes, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(name in inst.constructor.childContextTypes);
292
+ !(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) : undefined;
325
293
  }
326
294
  return assign({}, currentContext, childContext);
327
295
  }
@@ -338,8 +306,8 @@ var ReactCompositeComponentMixin = {
338
306
  * @private
339
307
  */
340
308
  _processProps: function (newProps) {
341
- if ('production' !== process.env.NODE_ENV) {
342
- var Component = ReactNativeComponent.getComponentClassForElement(this._currentElement);
309
+ if (process.env.NODE_ENV !== 'production') {
310
+ var Component = this._currentElement.type;
343
311
  if (Component.propTypes) {
344
312
  this._checkPropTypes(Component.propTypes, newProps, ReactPropTypeLocations.prop);
345
313
  }
@@ -365,7 +333,7 @@ var ReactCompositeComponentMixin = {
365
333
  try {
366
334
  // This is intentionally an invariant that gets caught. It's the same
367
335
  // behavior as without this statement except with a better message.
368
- 'production' !== process.env.NODE_ENV ? invariant(typeof propTypes[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(typeof propTypes[propName] === 'function');
336
+ !(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
369
337
  error = propTypes[propName](props, propName, componentName, location);
370
338
  } catch (ex) {
371
339
  error = ex;
@@ -378,9 +346,9 @@ var ReactCompositeComponentMixin = {
378
346
 
379
347
  if (location === ReactPropTypeLocations.prop) {
380
348
  // Preface gives us something to blacklist in warning module
381
- 'production' !== process.env.NODE_ENV ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : null;
349
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : undefined;
382
350
  } else {
383
- 'production' !== process.env.NODE_ENV ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : null;
351
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : undefined;
384
352
  }
385
353
  }
386
354
  }
@@ -409,10 +377,6 @@ var ReactCompositeComponentMixin = {
409
377
  }
410
378
 
411
379
  if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
412
- if ('production' !== process.env.NODE_ENV) {
413
- ReactElementValidator.checkAndWarnForMutatedProps(this._currentElement);
414
- }
415
-
416
380
  this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context);
417
381
  }
418
382
  },
@@ -435,14 +399,16 @@ var ReactCompositeComponentMixin = {
435
399
  updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
436
400
  var inst = this._instance;
437
401
 
438
- var nextContext = inst.context;
439
- var nextProps = inst.props;
402
+ var nextContext = this._context === nextUnmaskedContext ? inst.context : this._processContext(nextUnmaskedContext);
403
+ var nextProps;
440
404
 
441
405
  // Distinguish between a props update versus a simple state update
442
- if (prevParentElement !== nextParentElement) {
443
- nextContext = this._processContext(nextUnmaskedContext);
406
+ if (prevParentElement === nextParentElement) {
407
+ // Skip checking prop types again -- we don't read inst.props to avoid
408
+ // warning for DOM component props in this upgrade
409
+ nextProps = nextParentElement.props;
410
+ } else {
444
411
  nextProps = this._processProps(nextParentElement.props);
445
-
446
412
  // An update here will schedule an update but immediately set
447
413
  // _pendingStateQueue which will ensure that any state updates gets
448
414
  // immediately reconciled instead of waiting for the next batch.
@@ -456,8 +422,8 @@ var ReactCompositeComponentMixin = {
456
422
 
457
423
  var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext);
458
424
 
459
- if ('production' !== process.env.NODE_ENV) {
460
- 'production' !== process.env.NODE_ENV ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : null;
425
+ if (process.env.NODE_ENV !== 'production') {
426
+ process.env.NODE_ENV !== 'production' ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : undefined;
461
427
  }
462
428
 
463
429
  if (shouldUpdate) {
@@ -514,9 +480,15 @@ var ReactCompositeComponentMixin = {
514
480
  _performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
515
481
  var inst = this._instance;
516
482
 
517
- var prevProps = inst.props;
518
- var prevState = inst.state;
519
- var prevContext = inst.context;
483
+ var hasComponentDidUpdate = Boolean(inst.componentDidUpdate);
484
+ var prevProps;
485
+ var prevState;
486
+ var prevContext;
487
+ if (hasComponentDidUpdate) {
488
+ prevProps = inst.props;
489
+ prevState = inst.state;
490
+ prevContext = inst.context;
491
+ }
520
492
 
521
493
  if (inst.componentWillUpdate) {
522
494
  inst.componentWillUpdate(nextProps, nextState, nextContext);
@@ -530,7 +502,7 @@ var ReactCompositeComponentMixin = {
530
502
 
531
503
  this._updateRenderedComponent(transaction, unmaskedContext);
532
504
 
533
- if (inst.componentDidUpdate) {
505
+ if (hasComponentDidUpdate) {
534
506
  transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst);
535
507
  }
536
508
  },
@@ -553,7 +525,7 @@ var ReactCompositeComponentMixin = {
553
525
  var prevComponentID = prevComponentInstance._rootNodeID;
554
526
  ReactReconciler.unmountComponent(prevComponentInstance);
555
527
 
556
- this._renderedComponent = this._instantiateReactComponent(nextRenderedElement, this._currentElement.type);
528
+ this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
557
529
  var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, thisID, transaction, this._processChildContext(context));
558
530
  this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
559
531
  }
@@ -572,7 +544,7 @@ var ReactCompositeComponentMixin = {
572
544
  _renderValidatedComponentWithoutOwnerOrContext: function () {
573
545
  var inst = this._instance;
574
546
  var renderedComponent = inst.render();
575
- if ('production' !== process.env.NODE_ENV) {
547
+ if (process.env.NODE_ENV !== 'production') {
576
548
  // We allow auto-mocks to proceed as if they're returning null.
577
549
  if (typeof renderedComponent === 'undefined' && inst.render._isMockFunction) {
578
550
  // This is probably bad practice. Consider warning here and
@@ -589,18 +561,15 @@ var ReactCompositeComponentMixin = {
589
561
  */
590
562
  _renderValidatedComponent: function () {
591
563
  var renderedComponent;
592
- var previousContext = ReactContext.current;
593
- ReactContext.current = this._processChildContext(this._currentElement._context);
594
564
  ReactCurrentOwner.current = this;
595
565
  try {
596
566
  renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext();
597
567
  } finally {
598
- ReactContext.current = previousContext;
599
568
  ReactCurrentOwner.current = null;
600
569
  }
601
- 'production' !== process.env.NODE_ENV ? invariant(
570
+ !(
602
571
  // TODO: An `isValidNode` function would probably be more appropriate
603
- renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent), '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent));
572
+ renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
604
573
  return renderedComponent;
605
574
  },
606
575