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
@@ -23,11 +23,11 @@ var ReactTransitionChildMapping = {
23
23
  * @param {*} children `this.props.children`
24
24
  * @return {object} Mapping of key to child
25
25
  */
26
- getChildMapping: function(children) {
26
+ getChildMapping: function (children) {
27
27
  if (!children) {
28
28
  return children;
29
29
  }
30
- return ReactFragment.extract(ReactChildren.map(children, function(child) {
30
+ return ReactFragment.extract(ReactChildren.map(children, function (child) {
31
31
  return child;
32
32
  }));
33
33
  },
@@ -49,7 +49,7 @@ var ReactTransitionChildMapping = {
49
49
  * @return {object} a key set that contains all keys in `prev` and all keys
50
50
  * in `next` in a reasonable order.
51
51
  */
52
- mergeChildMappings: function(prev, next) {
52
+ mergeChildMappings: function (prev, next) {
53
53
  prev = prev || {};
54
54
  next = next || {};
55
55
 
@@ -83,9 +83,7 @@ var ReactTransitionChildMapping = {
83
83
  if (nextKeysPending.hasOwnProperty(nextKey)) {
84
84
  for (i = 0; i < nextKeysPending[nextKey].length; i++) {
85
85
  var pendingNextKey = nextKeysPending[nextKey][i];
86
- childMapping[nextKeysPending[nextKey][i]] = getValueForKey(
87
- pendingNextKey
88
- );
86
+ childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
89
87
  }
90
88
  }
91
89
  childMapping[nextKey] = getValueForKey(nextKey);
@@ -100,4 +98,4 @@ var ReactTransitionChildMapping = {
100
98
  }
101
99
  };
102
100
 
103
- module.exports = ReactTransitionChildMapping;
101
+ module.exports = ReactTransitionChildMapping;
@@ -84,26 +84,26 @@ function removeEventListener(node, eventName, eventListener) {
84
84
  }
85
85
 
86
86
  var ReactTransitionEvents = {
87
- addEndEventListener: function(node, eventListener) {
87
+ addEndEventListener: function (node, eventListener) {
88
88
  if (endEvents.length === 0) {
89
89
  // If CSS transitions are not supported, trigger an "end animation"
90
90
  // event immediately.
91
91
  window.setTimeout(eventListener, 0);
92
92
  return;
93
93
  }
94
- endEvents.forEach(function(endEvent) {
94
+ endEvents.forEach(function (endEvent) {
95
95
  addEventListener(node, endEvent, eventListener);
96
96
  });
97
97
  },
98
98
 
99
- removeEndEventListener: function(node, eventListener) {
99
+ removeEndEventListener: function (node, eventListener) {
100
100
  if (endEvents.length === 0) {
101
101
  return;
102
102
  }
103
- endEvents.forEach(function(endEvent) {
103
+ endEvents.forEach(function (endEvent) {
104
104
  removeEventListener(node, endEvent, eventListener);
105
105
  });
106
106
  }
107
107
  };
108
108
 
109
- module.exports = ReactTransitionEvents;
109
+ module.exports = ReactTransitionEvents;
@@ -26,26 +26,26 @@ var ReactTransitionGroup = React.createClass({
26
26
  childFactory: React.PropTypes.func
27
27
  },
28
28
 
29
- getDefaultProps: function() {
29
+ getDefaultProps: function () {
30
30
  return {
31
31
  component: 'span',
32
32
  childFactory: emptyFunction.thatReturnsArgument
33
33
  };
34
34
  },
35
35
 
36
- getInitialState: function() {
36
+ getInitialState: function () {
37
37
  return {
38
38
  children: ReactTransitionChildMapping.getChildMapping(this.props.children)
39
39
  };
40
40
  },
41
41
 
42
- componentWillMount: function() {
42
+ componentWillMount: function () {
43
43
  this.currentlyTransitioningKeys = {};
44
44
  this.keysToEnter = [];
45
45
  this.keysToLeave = [];
46
46
  },
47
47
 
48
- componentDidMount: function() {
48
+ componentDidMount: function () {
49
49
  var initialChildMapping = this.state.children;
50
50
  for (var key in initialChildMapping) {
51
51
  if (initialChildMapping[key]) {
@@ -54,33 +54,26 @@ var ReactTransitionGroup = React.createClass({
54
54
  }
55
55
  },
56
56
 
57
- componentWillReceiveProps: function(nextProps) {
58
- var nextChildMapping = ReactTransitionChildMapping.getChildMapping(
59
- nextProps.children
60
- );
57
+ componentWillReceiveProps: function (nextProps) {
58
+ var nextChildMapping = ReactTransitionChildMapping.getChildMapping(nextProps.children);
61
59
  var prevChildMapping = this.state.children;
62
60
 
63
61
  this.setState({
64
- children: ReactTransitionChildMapping.mergeChildMappings(
65
- prevChildMapping,
66
- nextChildMapping
67
- )
62
+ children: ReactTransitionChildMapping.mergeChildMappings(prevChildMapping, nextChildMapping)
68
63
  });
69
64
 
70
65
  var key;
71
66
 
72
67
  for (key in nextChildMapping) {
73
68
  var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
74
- if (nextChildMapping[key] && !hasPrev &&
75
- !this.currentlyTransitioningKeys[key]) {
69
+ if (nextChildMapping[key] && !hasPrev && !this.currentlyTransitioningKeys[key]) {
76
70
  this.keysToEnter.push(key);
77
71
  }
78
72
  }
79
73
 
80
74
  for (key in prevChildMapping) {
81
75
  var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
82
- if (prevChildMapping[key] && !hasNext &&
83
- !this.currentlyTransitioningKeys[key]) {
76
+ if (prevChildMapping[key] && !hasNext && !this.currentlyTransitioningKeys[key]) {
84
77
  this.keysToLeave.push(key);
85
78
  }
86
79
  }
@@ -88,7 +81,7 @@ var ReactTransitionGroup = React.createClass({
88
81
  // If we want to someday check for reordering, we could do it here.
89
82
  },
90
83
 
91
- componentDidUpdate: function() {
84
+ componentDidUpdate: function () {
92
85
  var keysToEnter = this.keysToEnter;
93
86
  this.keysToEnter = [];
94
87
  keysToEnter.forEach(this.performEnter);
@@ -98,21 +91,19 @@ var ReactTransitionGroup = React.createClass({
98
91
  keysToLeave.forEach(this.performLeave);
99
92
  },
100
93
 
101
- performAppear: function(key) {
94
+ performAppear: function (key) {
102
95
  this.currentlyTransitioningKeys[key] = true;
103
96
 
104
97
  var component = this.refs[key];
105
98
 
106
99
  if (component.componentWillAppear) {
107
- component.componentWillAppear(
108
- this._handleDoneAppearing.bind(this, key)
109
- );
100
+ component.componentWillAppear(this._handleDoneAppearing.bind(this, key));
110
101
  } else {
111
102
  this._handleDoneAppearing(key);
112
103
  }
113
104
  },
114
105
 
115
- _handleDoneAppearing: function(key) {
106
+ _handleDoneAppearing: function (key) {
116
107
  var component = this.refs[key];
117
108
  if (component.componentDidAppear) {
118
109
  component.componentDidAppear();
@@ -120,9 +111,7 @@ var ReactTransitionGroup = React.createClass({
120
111
 
121
112
  delete this.currentlyTransitioningKeys[key];
122
113
 
123
- var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
124
- this.props.children
125
- );
114
+ var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
126
115
 
127
116
  if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
128
117
  // This was removed before it had fully appeared. Remove it.
@@ -130,21 +119,19 @@ var ReactTransitionGroup = React.createClass({
130
119
  }
131
120
  },
132
121
 
133
- performEnter: function(key) {
122
+ performEnter: function (key) {
134
123
  this.currentlyTransitioningKeys[key] = true;
135
124
 
136
125
  var component = this.refs[key];
137
126
 
138
127
  if (component.componentWillEnter) {
139
- component.componentWillEnter(
140
- this._handleDoneEntering.bind(this, key)
141
- );
128
+ component.componentWillEnter(this._handleDoneEntering.bind(this, key));
142
129
  } else {
143
130
  this._handleDoneEntering(key);
144
131
  }
145
132
  },
146
133
 
147
- _handleDoneEntering: function(key) {
134
+ _handleDoneEntering: function (key) {
148
135
  var component = this.refs[key];
149
136
  if (component.componentDidEnter) {
150
137
  component.componentDidEnter();
@@ -152,9 +139,7 @@ var ReactTransitionGroup = React.createClass({
152
139
 
153
140
  delete this.currentlyTransitioningKeys[key];
154
141
 
155
- var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
156
- this.props.children
157
- );
142
+ var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
158
143
 
159
144
  if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
160
145
  // This was removed before it had fully entered. Remove it.
@@ -162,7 +147,7 @@ var ReactTransitionGroup = React.createClass({
162
147
  }
163
148
  },
164
149
 
165
- performLeave: function(key) {
150
+ performLeave: function (key) {
166
151
  this.currentlyTransitioningKeys[key] = true;
167
152
 
168
153
  var component = this.refs[key];
@@ -176,7 +161,7 @@ var ReactTransitionGroup = React.createClass({
176
161
  }
177
162
  },
178
163
 
179
- _handleDoneLeaving: function(key) {
164
+ _handleDoneLeaving: function (key) {
180
165
  var component = this.refs[key];
181
166
 
182
167
  if (component.componentDidLeave) {
@@ -185,21 +170,21 @@ var ReactTransitionGroup = React.createClass({
185
170
 
186
171
  delete this.currentlyTransitioningKeys[key];
187
172
 
188
- var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
189
- this.props.children
190
- );
173
+ var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
191
174
 
192
175
  if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
193
176
  // This entered again before it fully left. Add it again.
194
177
  this.performEnter(key);
195
178
  } else {
196
- var newChildren = assign({}, this.state.children);
197
- delete newChildren[key];
198
- this.setState({children: newChildren});
179
+ this.setState(function (state) {
180
+ var newChildren = assign({}, state.children);
181
+ delete newChildren[key];
182
+ return { children: newChildren };
183
+ });
199
184
  }
200
185
  },
201
186
 
202
- render: function() {
187
+ render: function () {
203
188
  // TODO: we could get rid of the need for the wrapper node
204
189
  // by cloning a single child
205
190
  var childrenToRender = [];
@@ -211,18 +196,11 @@ var ReactTransitionGroup = React.createClass({
211
196
  // already been removed. In case you need this behavior you can provide
212
197
  // a childFactory function to wrap every child, even the ones that are
213
198
  // leaving.
214
- childrenToRender.push(cloneWithProps(
215
- this.props.childFactory(child),
216
- {ref: key, key: key}
217
- ));
199
+ childrenToRender.push(cloneWithProps(this.props.childFactory(child), { ref: key, key: key }));
218
200
  }
219
201
  }
220
- return React.createElement(
221
- this.props.component,
222
- this.props,
223
- childrenToRender
224
- );
202
+ return React.createElement(this.props.component, this.props, childrenToRender);
225
203
  }
226
204
  });
227
205
 
228
- module.exports = ReactTransitionGroup;
206
+ module.exports = ReactTransitionGroup;
@@ -11,7 +11,6 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactLifeCycle = require("./ReactLifeCycle");
15
14
  var ReactCurrentOwner = require("./ReactCurrentOwner");
16
15
  var ReactElement = require("./ReactElement");
17
16
  var ReactInstanceMap = require("./ReactInstanceMap");
@@ -22,46 +21,25 @@ var invariant = require("./invariant");
22
21
  var warning = require("./warning");
23
22
 
24
23
  function enqueueUpdate(internalInstance) {
25
- if (internalInstance !== ReactLifeCycle.currentlyMountingInstance) {
26
- // If we're in a componentWillMount handler, don't enqueue a rerender
27
- // because ReactUpdates assumes we're in a browser context (which is
28
- // wrong for server rendering) and we're about to do a render anyway.
29
- // See bug in #1740.
30
- ReactUpdates.enqueueUpdate(internalInstance);
31
- }
24
+ ReactUpdates.enqueueUpdate(internalInstance);
32
25
  }
33
26
 
34
27
  function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
35
- ("production" !== process.env.NODE_ENV ? invariant(
36
- ReactCurrentOwner.current == null,
37
- '%s(...): Cannot update during an existing state transition ' +
38
- '(such as within `render`). Render methods should be a pure function ' +
39
- 'of props and state.',
40
- callerName
41
- ) : invariant(ReactCurrentOwner.current == null));
28
+ if ('production' !== process.env.NODE_ENV) {
29
+ 'production' !== process.env.NODE_ENV ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : undefined;
30
+ }
42
31
 
43
32
  var internalInstance = ReactInstanceMap.get(publicInstance);
44
33
  if (!internalInstance) {
45
- if ("production" !== process.env.NODE_ENV) {
34
+ if ('production' !== process.env.NODE_ENV) {
46
35
  // Only warn when we have a callerName. Otherwise we should be silent.
47
36
  // We're probably calling from enqueueCallback. We don't want to warn
48
37
  // there because we already warned for the corresponding lifecycle method.
49
- ("production" !== process.env.NODE_ENV ? warning(
50
- !callerName,
51
- '%s(...): Can only update a mounted or mounting component. ' +
52
- 'This usually means you called %s() on an unmounted ' +
53
- 'component. This is a no-op.',
54
- callerName,
55
- callerName
56
- ) : null);
38
+ 'production' !== process.env.NODE_ENV ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : undefined;
57
39
  }
58
40
  return null;
59
41
  }
60
42
 
61
- if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
62
- return null;
63
- }
64
-
65
43
  return internalInstance;
66
44
  }
67
45
 
@@ -71,6 +49,32 @@ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
71
49
  */
72
50
  var ReactUpdateQueue = {
73
51
 
52
+ /**
53
+ * Checks whether or not this composite component is mounted.
54
+ * @param {ReactClass} publicInstance The instance we want to test.
55
+ * @return {boolean} True if mounted, false otherwise.
56
+ * @protected
57
+ * @final
58
+ */
59
+ isMounted: function (publicInstance) {
60
+ if ('production' !== process.env.NODE_ENV) {
61
+ var owner = ReactCurrentOwner.current;
62
+ if (owner !== null) {
63
+ 'production' !== process.env.NODE_ENV ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
64
+ owner._warnedAboutRefsInRender = true;
65
+ }
66
+ }
67
+ var internalInstance = ReactInstanceMap.get(publicInstance);
68
+ if (internalInstance) {
69
+ // During componentWillMount and render this will still be null but after
70
+ // that will always render to something. At least for now. So we can use
71
+ // this hack.
72
+ return !!internalInstance._renderedComponent;
73
+ } else {
74
+ return false;
75
+ }
76
+ },
77
+
74
78
  /**
75
79
  * Enqueue a callback that will be executed after all the pending updates
76
80
  * have processed.
@@ -79,13 +83,8 @@ var ReactUpdateQueue = {
79
83
  * @param {?function} callback Called after state is updated.
80
84
  * @internal
81
85
  */
82
- enqueueCallback: function(publicInstance, callback) {
83
- ("production" !== process.env.NODE_ENV ? invariant(
84
- typeof callback === 'function',
85
- 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
86
- '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
87
- 'isn\'t callable.'
88
- ) : invariant(typeof callback === 'function'));
86
+ enqueueCallback: function (publicInstance, callback) {
87
+ !(typeof callback === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
89
88
  var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
90
89
 
91
90
  // Previously we would throw an error if we didn't have an internal
@@ -93,8 +92,7 @@ var ReactUpdateQueue = {
93
92
  // behavior we have in other enqueue* methods.
94
93
  // We also need to ignore callbacks in componentWillMount. See
95
94
  // enqueueUpdates.
96
- if (!internalInstance ||
97
- internalInstance === ReactLifeCycle.currentlyMountingInstance) {
95
+ if (!internalInstance) {
98
96
  return null;
99
97
  }
100
98
 
@@ -110,13 +108,8 @@ var ReactUpdateQueue = {
110
108
  enqueueUpdate(internalInstance);
111
109
  },
112
110
 
113
- enqueueCallbackInternal: function(internalInstance, callback) {
114
- ("production" !== process.env.NODE_ENV ? invariant(
115
- typeof callback === 'function',
116
- 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
117
- '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
118
- 'isn\'t callable.'
119
- ) : invariant(typeof callback === 'function'));
111
+ enqueueCallbackInternal: function (internalInstance, callback) {
112
+ !(typeof callback === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
120
113
  if (internalInstance._pendingCallbacks) {
121
114
  internalInstance._pendingCallbacks.push(callback);
122
115
  } else {
@@ -132,17 +125,14 @@ var ReactUpdateQueue = {
132
125
  * You may want to call this when you know that some deeper aspect of the
133
126
  * component's state has changed but `setState` was not called.
134
127
  *
135
- * This will not invoke `shouldUpdateComponent`, but it will invoke
128
+ * This will not invoke `shouldComponentUpdate`, but it will invoke
136
129
  * `componentWillUpdate` and `componentDidUpdate`.
137
130
  *
138
131
  * @param {ReactClass} publicInstance The instance that should rerender.
139
132
  * @internal
140
133
  */
141
- enqueueForceUpdate: function(publicInstance) {
142
- var internalInstance = getInternalInstanceReadyForUpdate(
143
- publicInstance,
144
- 'forceUpdate'
145
- );
134
+ enqueueForceUpdate: function (publicInstance) {
135
+ var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'forceUpdate');
146
136
 
147
137
  if (!internalInstance) {
148
138
  return;
@@ -164,11 +154,8 @@ var ReactUpdateQueue = {
164
154
  * @param {object} completeState Next state.
165
155
  * @internal
166
156
  */
167
- enqueueReplaceState: function(publicInstance, completeState) {
168
- var internalInstance = getInternalInstanceReadyForUpdate(
169
- publicInstance,
170
- 'replaceState'
171
- );
157
+ enqueueReplaceState: function (publicInstance, completeState) {
158
+ var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState');
172
159
 
173
160
  if (!internalInstance) {
174
161
  return;
@@ -190,19 +177,14 @@ var ReactUpdateQueue = {
190
177
  * @param {object} partialState Next partial state to be merged with state.
191
178
  * @internal
192
179
  */
193
- enqueueSetState: function(publicInstance, partialState) {
194
- var internalInstance = getInternalInstanceReadyForUpdate(
195
- publicInstance,
196
- 'setState'
197
- );
180
+ enqueueSetState: function (publicInstance, partialState) {
181
+ var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setState');
198
182
 
199
183
  if (!internalInstance) {
200
184
  return;
201
185
  }
202
186
 
203
- var queue =
204
- internalInstance._pendingStateQueue ||
205
- (internalInstance._pendingStateQueue = []);
187
+ var queue = internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = []);
206
188
  queue.push(partialState);
207
189
 
208
190
  enqueueUpdate(internalInstance);
@@ -215,36 +197,26 @@ var ReactUpdateQueue = {
215
197
  * @param {object} partialProps Subset of the next props.
216
198
  * @internal
217
199
  */
218
- enqueueSetProps: function(publicInstance, partialProps) {
219
- var internalInstance = getInternalInstanceReadyForUpdate(
220
- publicInstance,
221
- 'setProps'
222
- );
223
-
200
+ enqueueSetProps: function (publicInstance, partialProps) {
201
+ var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setProps');
224
202
  if (!internalInstance) {
225
203
  return;
226
204
  }
205
+ ReactUpdateQueue.enqueueSetPropsInternal(internalInstance, partialProps);
206
+ },
227
207
 
228
- ("production" !== process.env.NODE_ENV ? invariant(
229
- internalInstance._isTopLevel,
230
- 'setProps(...): You called `setProps` on a ' +
231
- 'component with a parent. This is an anti-pattern since props will ' +
232
- 'get reactively updated when rendered. Instead, change the owner\'s ' +
233
- '`render` method to pass the correct value as props to the component ' +
234
- 'where it is created.'
235
- ) : invariant(internalInstance._isTopLevel));
208
+ enqueueSetPropsInternal: function (internalInstance, partialProps) {
209
+ var topLevelWrapper = internalInstance._topLevelWrapper;
210
+ !topLevelWrapper ? 'production' !== process.env.NODE_ENV ? invariant(false, 'setProps(...): You called `setProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
236
211
 
237
212
  // Merge with the pending element if it exists, otherwise with existing
238
213
  // element props.
239
- var element = internalInstance._pendingElement ||
240
- internalInstance._currentElement;
214
+ var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
215
+ var element = wrapElement.props;
241
216
  var props = assign({}, element.props, partialProps);
242
- internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
243
- element,
244
- props
245
- );
217
+ topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
246
218
 
247
- enqueueUpdate(internalInstance);
219
+ enqueueUpdate(topLevelWrapper);
248
220
  },
249
221
 
250
222
  /**
@@ -254,42 +226,32 @@ var ReactUpdateQueue = {
254
226
  * @param {object} props New props.
255
227
  * @internal
256
228
  */
257
- enqueueReplaceProps: function(publicInstance, props) {
258
- var internalInstance = getInternalInstanceReadyForUpdate(
259
- publicInstance,
260
- 'replaceProps'
261
- );
262
-
229
+ enqueueReplaceProps: function (publicInstance, props) {
230
+ var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceProps');
263
231
  if (!internalInstance) {
264
232
  return;
265
233
  }
234
+ ReactUpdateQueue.enqueueReplacePropsInternal(internalInstance, props);
235
+ },
266
236
 
267
- ("production" !== process.env.NODE_ENV ? invariant(
268
- internalInstance._isTopLevel,
269
- 'replaceProps(...): You called `replaceProps` on a ' +
270
- 'component with a parent. This is an anti-pattern since props will ' +
271
- 'get reactively updated when rendered. Instead, change the owner\'s ' +
272
- '`render` method to pass the correct value as props to the component ' +
273
- 'where it is created.'
274
- ) : invariant(internalInstance._isTopLevel));
237
+ enqueueReplacePropsInternal: function (internalInstance, props) {
238
+ var topLevelWrapper = internalInstance._topLevelWrapper;
239
+ !topLevelWrapper ? 'production' !== process.env.NODE_ENV ? invariant(false, 'replaceProps(...): You called `replaceProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
275
240
 
276
241
  // Merge with the pending element if it exists, otherwise with existing
277
242
  // element props.
278
- var element = internalInstance._pendingElement ||
279
- internalInstance._currentElement;
280
- internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
281
- element,
282
- props
283
- );
243
+ var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
244
+ var element = wrapElement.props;
245
+ topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
284
246
 
285
- enqueueUpdate(internalInstance);
247
+ enqueueUpdate(topLevelWrapper);
286
248
  },
287
249
 
288
- enqueueElementInternal: function(internalInstance, newElement) {
250
+ enqueueElementInternal: function (internalInstance, newElement) {
289
251
  internalInstance._pendingElement = newElement;
290
252
  enqueueUpdate(internalInstance);
291
253
  }
292
254
 
293
255
  };
294
256
 
295
- module.exports = ReactUpdateQueue;
257
+ module.exports = ReactUpdateQueue;