react 0.13.1 → 0.14.0-alpha2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/README.md +1 -1
  2. package/addons.js +7 -0
  3. package/addons/CSSTransitionGroup.js +1 -0
  4. package/addons/LinkedStateMixin.js +1 -0
  5. package/addons/Perf.js +1 -0
  6. package/addons/PureRenderMixin.js +1 -0
  7. package/addons/TestUtils.js +1 -0
  8. package/addons/TransitionGroup.js +1 -0
  9. package/addons/batchedUpdates.js +1 -0
  10. package/addons/cloneWithProps.js +1 -0
  11. package/addons/createFragment.js +1 -0
  12. package/addons/renderSubtreeIntoContainer.js +1 -0
  13. package/addons/shallowCompare.js +1 -0
  14. package/addons/update.js +1 -0
  15. package/dist/JSXTransformer.js +3336 -1671
  16. package/dist/react-with-addons.js +3320 -5125
  17. package/dist/react-with-addons.min.js +6 -6
  18. package/dist/react.js +2952 -4533
  19. package/dist/react.min.js +5 -5
  20. package/lib/AutoFocusMixin.js +4 -3
  21. package/lib/BeforeInputEventPlugin.js +30 -118
  22. package/lib/CSSCore.js +12 -23
  23. package/lib/CSSProperty.js +9 -4
  24. package/lib/CSSPropertyOperations.js +14 -30
  25. package/lib/CallbackQueue.js +7 -10
  26. package/lib/ChangeEventPlugin.js +24 -88
  27. package/lib/ClientReactRootIndex.js +2 -2
  28. package/lib/DOMChildrenOperations.js +13 -33
  29. package/lib/DOMProperty.js +41 -67
  30. package/lib/DOMPropertyOperations.js +30 -51
  31. package/lib/Danger.js +19 -62
  32. package/lib/DefaultEventPluginOrder.js +2 -12
  33. package/lib/EnterLeaveEventPlugin.js +11 -33
  34. package/lib/EventConstants.js +2 -2
  35. package/lib/EventListener.js +11 -13
  36. package/lib/EventPluginHub.js +44 -47
  37. package/lib/EventPluginRegistry.js +18 -74
  38. package/lib/EventPluginUtils.js +27 -38
  39. package/lib/EventPropagators.js +23 -26
  40. package/lib/ExecutionEnvironment.js +4 -8
  41. package/lib/FallbackCompositionState.js +3 -3
  42. package/lib/HTMLDOMPropertyConfig.js +13 -20
  43. package/lib/LinkedStateMixin.js +3 -6
  44. package/lib/LinkedValueUtils.js +34 -64
  45. package/lib/LocalEventTrapMixin.js +9 -16
  46. package/lib/Object.assign.js +1 -1
  47. package/lib/PooledClass.js +8 -11
  48. package/lib/React.js +9 -129
  49. package/lib/ReactBrowserComponentMixin.js +9 -2
  50. package/lib/ReactBrowserEventEmitter.js +26 -82
  51. package/lib/ReactCSSTransitionGroup.js +13 -24
  52. package/lib/ReactCSSTransitionGroupChild.js +18 -28
  53. package/lib/ReactChildReconciler.js +11 -19
  54. package/lib/ReactChildren.js +21 -28
  55. package/lib/ReactClass.js +81 -234
  56. package/lib/ReactComponent.js +17 -33
  57. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  58. package/lib/ReactComponentEnvironment.js +6 -12
  59. package/lib/ReactComponentWithPureRenderMixin.js +4 -5
  60. package/lib/ReactCompositeComponent.js +85 -297
  61. package/lib/ReactContext.js +2 -44
  62. package/lib/ReactCurrentOwner.js +1 -3
  63. package/lib/ReactDOM.js +4 -2
  64. package/lib/ReactDOMButton.js +3 -4
  65. package/lib/ReactDOMClient.js +85 -0
  66. package/lib/ReactDOMComponent.js +184 -146
  67. package/lib/ReactDOMForm.js +3 -3
  68. package/lib/ReactDOMIDOperations.js +11 -22
  69. package/lib/ReactDOMIframe.js +3 -3
  70. package/lib/ReactDOMImg.js +3 -3
  71. package/lib/ReactDOMInput.js +22 -35
  72. package/lib/ReactDOMOption.js +68 -10
  73. package/lib/ReactDOMSelect.js +50 -28
  74. package/lib/ReactDOMSelection.js +5 -20
  75. package/lib/ReactDOMServer.js +24 -0
  76. package/lib/ReactDOMTextComponent.js +17 -18
  77. package/lib/ReactDOMTextarea.js +15 -27
  78. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  79. package/lib/ReactDefaultInjection.js +31 -40
  80. package/lib/ReactDefaultPerf.js +36 -69
  81. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  82. package/lib/ReactElement.js +24 -57
  83. package/lib/ReactElementValidator.js +38 -105
  84. package/lib/ReactEmptyComponent.js +7 -11
  85. package/lib/ReactErrorUtils.js +2 -2
  86. package/lib/ReactEventEmitterMixin.js +3 -12
  87. package/lib/ReactEventListener.js +16 -38
  88. package/lib/ReactFragment.js +23 -54
  89. package/lib/ReactInjection.js +1 -1
  90. package/lib/ReactInputSelection.js +11 -21
  91. package/lib/ReactInstanceHandles.js +27 -57
  92. package/lib/ReactInstanceMap.js +5 -5
  93. package/lib/ReactIsomorphic.js +70 -0
  94. package/lib/ReactLifeCycle.js +1 -1
  95. package/lib/ReactLink.js +2 -4
  96. package/lib/ReactMarkupChecksum.js +5 -10
  97. package/lib/ReactMount.js +137 -260
  98. package/lib/ReactMultiChild.js +19 -45
  99. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  100. package/lib/ReactNativeComponent.js +7 -11
  101. package/lib/ReactOwner.js +7 -24
  102. package/lib/ReactPerf.js +8 -12
  103. package/lib/ReactPropTransferer.js +4 -4
  104. package/lib/ReactPropTypeLocationNames.js +2 -2
  105. package/lib/ReactPropTypeLocations.js +1 -1
  106. package/lib/ReactPropTypes.js +29 -61
  107. package/lib/ReactReconcileTransaction.js +9 -34
  108. package/lib/ReactReconciler.js +9 -19
  109. package/lib/ReactRef.js +5 -8
  110. package/lib/ReactRootIndex.js +2 -2
  111. package/lib/ReactServerRendering.js +7 -15
  112. package/lib/ReactServerRenderingTransaction.js +7 -32
  113. package/lib/ReactStateSetters.js +6 -6
  114. package/lib/ReactTestUtils.js +93 -165
  115. package/lib/ReactTransitionChildMapping.js +5 -7
  116. package/lib/ReactTransitionEvents.js +5 -5
  117. package/lib/ReactTransitionGroup.js +30 -52
  118. package/lib/ReactUpdateQueue.js +27 -90
  119. package/lib/ReactUpdates.js +27 -79
  120. package/lib/ReactWithAddons.js +7 -6
  121. package/lib/SVGDOMPropertyConfig.js +41 -4
  122. package/lib/SelectEventPlugin.js +28 -29
  123. package/lib/ServerReactRootIndex.js +2 -2
  124. package/lib/SimpleEventPlugin.js +136 -128
  125. package/lib/SyntheticClipboardEvent.js +3 -7
  126. package/lib/SyntheticCompositionEvent.js +3 -9
  127. package/lib/SyntheticDragEvent.js +1 -1
  128. package/lib/SyntheticEvent.js +8 -10
  129. package/lib/SyntheticFocusEvent.js +1 -1
  130. package/lib/SyntheticInputEvent.js +3 -9
  131. package/lib/SyntheticKeyboardEvent.js +4 -4
  132. package/lib/SyntheticMouseEvent.js +8 -14
  133. package/lib/SyntheticTouchEvent.js +1 -1
  134. package/lib/SyntheticUIEvent.js +3 -3
  135. package/lib/SyntheticWheelEvent.js +11 -15
  136. package/lib/Transaction.js +12 -24
  137. package/lib/ViewportMetrics.js +2 -2
  138. package/lib/accumulateInto.js +2 -5
  139. package/lib/adler32.js +2 -4
  140. package/lib/camelize.js +4 -2
  141. package/lib/camelizeStyleName.js +2 -2
  142. package/lib/cloneWithProps.js +5 -11
  143. package/lib/containsNode.js +29 -16
  144. package/lib/createArrayFromMixed.js +17 -16
  145. package/lib/createFullPageComponent.js +4 -11
  146. package/lib/createNodesFromMarkup.js +6 -8
  147. package/lib/dangerousStyleValue.js +2 -3
  148. package/lib/emptyFunction.js +10 -4
  149. package/lib/emptyObject.js +1 -1
  150. package/lib/escapeTextContentForBrowser.js +1 -1
  151. package/lib/findDOMNode.js +5 -24
  152. package/lib/flattenChildren.js +4 -10
  153. package/lib/focusNode.js +2 -3
  154. package/lib/forEachAccumulated.js +2 -2
  155. package/lib/getActiveElement.js +4 -2
  156. package/lib/getEventCharCode.js +1 -1
  157. package/lib/getEventKey.js +1 -1
  158. package/lib/getEventModifierState.js +1 -1
  159. package/lib/getEventTarget.js +1 -1
  160. package/lib/getIteratorFn.js +2 -4
  161. package/lib/getMarkupWrap.js +7 -5
  162. package/lib/getNodeForCharacterOffset.js +1 -1
  163. package/lib/getTextContentAccessor.js +2 -4
  164. package/lib/getUnboundedScrollPosition.js +1 -1
  165. package/lib/hyphenate.js +3 -1
  166. package/lib/hyphenateStyleName.js +2 -2
  167. package/lib/instantiateReactComponent.js +14 -37
  168. package/lib/invariant.js +8 -12
  169. package/lib/isEventSupported.js +7 -10
  170. package/lib/isNode.js +4 -6
  171. package/lib/isTextInputElement.js +2 -4
  172. package/lib/isTextNode.js +3 -1
  173. package/lib/joinClasses.js +2 -2
  174. package/lib/keyMirror.js +3 -6
  175. package/lib/keyOf.js +4 -3
  176. package/lib/mapObject.js +1 -1
  177. package/lib/memoizeStringOnly.js +2 -2
  178. package/lib/onlyChild.js +2 -5
  179. package/lib/performance.js +2 -5
  180. package/lib/performanceNow.js +3 -1
  181. package/lib/quoteAttributeValueForBrowser.js +1 -1
  182. package/lib/renderSubtreeIntoContainer.js +16 -0
  183. package/lib/setInnerHTML.js +11 -8
  184. package/lib/setTextContent.js +3 -3
  185. package/lib/shallowCompare.js +24 -0
  186. package/lib/shallowEqual.js +17 -11
  187. package/lib/shouldUpdateReactComponent.js +3 -64
  188. package/lib/toArray.js +8 -19
  189. package/lib/traverseAllChildren.js +22 -89
  190. package/lib/update.js +33 -90
  191. package/lib/validateDOMNesting.js +355 -0
  192. package/lib/warning.js +17 -15
  193. package/package.json +3 -3
  194. package/lib/MobileSafariClickEventPlugin.js +0 -56
  195. package/lib/ReactPutListenerQueue.js +0 -54
  196. package/lib/cx.js +0 -52
  197. package/lib/getReactRootElementInContainer.js +0 -33
@@ -26,22 +26,22 @@ var ReactInstanceMap = {
26
26
  * transform these to strings for IE support. When this transform is fully
27
27
  * supported we can rename it.
28
28
  */
29
- remove: function(key) {
29
+ remove: function (key) {
30
30
  key._reactInternalInstance = undefined;
31
31
  },
32
32
 
33
- get: function(key) {
33
+ get: function (key) {
34
34
  return key._reactInternalInstance;
35
35
  },
36
36
 
37
- has: function(key) {
37
+ has: function (key) {
38
38
  return key._reactInternalInstance !== undefined;
39
39
  },
40
40
 
41
- set: function(key, value) {
41
+ set: function (key, value) {
42
42
  key._reactInternalInstance = value;
43
43
  }
44
44
 
45
45
  };
46
46
 
47
- module.exports = ReactInstanceMap;
47
+ module.exports = ReactInstanceMap;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright 2013-2015, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule ReactIsomorphic
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactChildren = require("./ReactChildren");
15
+ var ReactComponent = require("./ReactComponent");
16
+ var ReactClass = require("./ReactClass");
17
+ var ReactDOM = require("./ReactDOM");
18
+ var ReactElement = require("./ReactElement");
19
+ var ReactElementValidator = require("./ReactElementValidator");
20
+ var ReactPropTypes = require("./ReactPropTypes");
21
+
22
+ var assign = require("./Object.assign");
23
+ var onlyChild = require("./onlyChild");
24
+
25
+ var createElement = ReactElement.createElement;
26
+ var createFactory = ReactElement.createFactory;
27
+ var cloneElement = ReactElement.cloneElement;
28
+
29
+ if ('production' !== process.env.NODE_ENV) {
30
+ createElement = ReactElementValidator.createElement;
31
+ createFactory = ReactElementValidator.createFactory;
32
+ cloneElement = ReactElementValidator.cloneElement;
33
+ }
34
+
35
+ var React = {
36
+
37
+ // Modern
38
+
39
+ Children: {
40
+ map: ReactChildren.map,
41
+ forEach: ReactChildren.forEach,
42
+ count: ReactChildren.count,
43
+ only: onlyChild
44
+ },
45
+
46
+ Component: ReactComponent,
47
+
48
+ createElement: createElement,
49
+ cloneElement: cloneElement,
50
+ isValidElement: ReactElement.isValidElement,
51
+
52
+ // Classic
53
+
54
+ PropTypes: ReactPropTypes,
55
+ createClass: ReactClass.createClass,
56
+ createFactory: createFactory,
57
+ createMixin: function (mixin) {
58
+ // Currently a noop. Will be used to validate and trace mixins.
59
+ return mixin;
60
+ },
61
+
62
+ // This looks DOM specific but these are actually isomorphic helpers
63
+ // since they are just generating DOM strings.
64
+ DOM: ReactDOM,
65
+
66
+ // Hook for JSX spread, don't use this for anything else.
67
+ __spread: assign
68
+ };
69
+
70
+ module.exports = React;
@@ -32,4 +32,4 @@ var ReactLifeCycle = {
32
32
  currentlyUnmountingInstance: null
33
33
  };
34
34
 
35
- module.exports = ReactLifeCycle;
35
+ module.exports = ReactLifeCycle;
package/lib/ReactLink.js CHANGED
@@ -56,9 +56,7 @@ function ReactLink(value, requestChange) {
56
56
  */
57
57
  function createLinkTypeChecker(linkType) {
58
58
  var shapes = {
59
- value: typeof linkType === 'undefined' ?
60
- React.PropTypes.any.isRequired :
61
- linkType.isRequired,
59
+ value: typeof linkType === 'undefined' ? React.PropTypes.any.isRequired : linkType.isRequired,
62
60
  requestChange: React.PropTypes.func.isRequired
63
61
  };
64
62
  return React.PropTypes.shape(shapes);
@@ -68,4 +66,4 @@ ReactLink.PropTypes = {
68
66
  link: createLinkTypeChecker
69
67
  };
70
68
 
71
- module.exports = ReactLink;
69
+ module.exports = ReactLink;
@@ -20,12 +20,9 @@ var ReactMarkupChecksum = {
20
20
  * @param {string} markup Markup string
21
21
  * @return {string} Markup string with checksum attribute attached
22
22
  */
23
- addChecksumToMarkup: function(markup) {
23
+ addChecksumToMarkup: function (markup) {
24
24
  var checksum = adler32(markup);
25
- return markup.replace(
26
- '>',
27
- ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">'
28
- );
25
+ return markup.replace('>', ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">');
29
26
  },
30
27
 
31
28
  /**
@@ -33,14 +30,12 @@ var ReactMarkupChecksum = {
33
30
  * @param {DOMElement} element root React element
34
31
  * @returns {boolean} whether or not the markup is the same
35
32
  */
36
- canReuseMarkup: function(markup, element) {
37
- var existingChecksum = element.getAttribute(
38
- ReactMarkupChecksum.CHECKSUM_ATTR_NAME
39
- );
33
+ canReuseMarkup: function (markup, element) {
34
+ var existingChecksum = element.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
40
35
  existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
41
36
  var markupChecksum = adler32(markup);
42
37
  return markupChecksum === existingChecksum;
43
38
  }
44
39
  };
45
40
 
46
- module.exports = ReactMarkupChecksum;
41
+ module.exports = ReactMarkupChecksum;
package/lib/ReactMount.js CHANGED
@@ -27,11 +27,11 @@ var ReactUpdates = require("./ReactUpdates");
27
27
 
28
28
  var emptyObject = require("./emptyObject");
29
29
  var containsNode = require("./containsNode");
30
- var getReactRootElementInContainer = require("./getReactRootElementInContainer");
31
30
  var instantiateReactComponent = require("./instantiateReactComponent");
32
31
  var invariant = require("./invariant");
33
32
  var setInnerHTML = require("./setInnerHTML");
34
33
  var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
34
+ var validateDOMNesting = require("./validateDOMNesting");
35
35
  var warning = require("./warning");
36
36
 
37
37
  var SEPARATOR = ReactInstanceHandles.SEPARATOR;
@@ -41,6 +41,7 @@ var nodeCache = {};
41
41
 
42
42
  var ELEMENT_NODE_TYPE = 1;
43
43
  var DOC_NODE_TYPE = 9;
44
+ var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
44
45
 
45
46
  /** Mapping from reactRootID to React component instance. */
46
47
  var instancesByReactRootID = {};
@@ -48,7 +49,7 @@ var instancesByReactRootID = {};
48
49
  /** Mapping from reactRootID to `container` nodes. */
49
50
  var containersByReactRootID = {};
50
51
 
51
- if ("production" !== process.env.NODE_ENV) {
52
+ if ('production' !== process.env.NODE_ENV) {
52
53
  /** __DEV__-only mapping from reactRootID to root elements. */
53
54
  var rootElementsByReactRootID = {};
54
55
  }
@@ -72,6 +73,23 @@ function firstDifferenceIndex(string1, string2) {
72
73
  return string1.length === string2.length ? -1 : minLen;
73
74
  }
74
75
 
76
+ /**
77
+ * @param {DOMElement|DOMDocument} container DOM element that may contain
78
+ * a React component
79
+ * @return {?*} DOM element that may have the reactRoot ID, or null.
80
+ */
81
+ function getReactRootElementInContainer(container) {
82
+ if (!container) {
83
+ return null;
84
+ }
85
+
86
+ if (container.nodeType === DOC_NODE_TYPE) {
87
+ return container.documentElement;
88
+ } else {
89
+ return container.firstChild;
90
+ }
91
+ }
92
+
75
93
  /**
76
94
  * @param {DOMElement} container DOM element that may contain a React component.
77
95
  * @return {?string} A "reactRoot" ID, if a React component is rendered.
@@ -97,11 +115,7 @@ function getID(node) {
97
115
  if (nodeCache.hasOwnProperty(id)) {
98
116
  var cached = nodeCache[id];
99
117
  if (cached !== node) {
100
- ("production" !== process.env.NODE_ENV ? invariant(
101
- !isValid(cached, id),
102
- 'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
103
- ATTR_NAME, id
104
- ) : invariant(!isValid(cached, id)));
118
+ 'production' !== process.env.NODE_ENV ? invariant(!isValid(cached, id), 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(!isValid(cached, id));
105
119
 
106
120
  nodeCache[id] = node;
107
121
  }
@@ -179,11 +193,7 @@ function getNodeFromInstance(instance) {
179
193
  */
180
194
  function isValid(node, id) {
181
195
  if (node) {
182
- ("production" !== process.env.NODE_ENV ? invariant(
183
- internalGetID(node) === id,
184
- 'ReactMount: Unexpected modification of `%s`',
185
- ATTR_NAME
186
- ) : invariant(internalGetID(node) === id));
196
+ 'production' !== process.env.NODE_ENV ? invariant(internalGetID(node) === id, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(internalGetID(node) === id);
187
197
 
188
198
  var container = ReactMount.findReactContainerForID(id);
189
199
  if (container && containsNode(container, node)) {
@@ -220,10 +230,7 @@ function findDeepestCachedAncestorImpl(ancestorID) {
220
230
  */
221
231
  function findDeepestCachedAncestor(targetID) {
222
232
  deepestNodeSoFar = null;
223
- ReactInstanceHandles.traverseAncestors(
224
- targetID,
225
- findDeepestCachedAncestorImpl
226
- );
233
+ ReactInstanceHandles.traverseAncestors(targetID, findDeepestCachedAncestorImpl);
227
234
 
228
235
  var foundNode = deepestNodeSoFar;
229
236
  deepestNodeSoFar = null;
@@ -239,15 +246,15 @@ function findDeepestCachedAncestor(targetID) {
239
246
  * @param {ReactReconcileTransaction} transaction
240
247
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
241
248
  */
242
- function mountComponentIntoNode(
243
- componentInstance,
244
- rootID,
245
- container,
246
- transaction,
247
- shouldReuseMarkup) {
248
- var markup = ReactReconciler.mountComponent(
249
- componentInstance, rootID, transaction, emptyObject
250
- );
249
+ function mountComponentIntoNode(componentInstance, rootID, container, transaction, shouldReuseMarkup, context) {
250
+ if ('production' !== process.env.NODE_ENV) {
251
+ if (context === emptyObject) {
252
+ context = {};
253
+ }
254
+ var tag = container.nodeName.toLowerCase();
255
+ context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
256
+ }
257
+ var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
251
258
  componentInstance._isTopLevel = true;
252
259
  ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
253
260
  }
@@ -260,24 +267,34 @@ function mountComponentIntoNode(
260
267
  * @param {DOMElement} container DOM element to mount into.
261
268
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
262
269
  */
263
- function batchedMountComponentIntoNode(
264
- componentInstance,
265
- rootID,
266
- container,
267
- shouldReuseMarkup) {
270
+ function batchedMountComponentIntoNode(componentInstance, rootID, container, shouldReuseMarkup, context) {
268
271
  var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
269
- transaction.perform(
270
- mountComponentIntoNode,
271
- null,
272
- componentInstance,
273
- rootID,
274
- container,
275
- transaction,
276
- shouldReuseMarkup
277
- );
272
+ transaction.perform(mountComponentIntoNode, null, componentInstance, rootID, container, transaction, shouldReuseMarkup, context);
278
273
  ReactUpdates.ReactReconcileTransaction.release(transaction);
279
274
  }
280
275
 
276
+ /**
277
+ * Unmounts a component and removes it from the DOM.
278
+ *
279
+ * @param {ReactComponent} instance React component instance.
280
+ * @param {DOMElement} container DOM element to unmount from.
281
+ * @final
282
+ * @internal
283
+ * @see {ReactMount.unmountComponentAtNode}
284
+ */
285
+ function unmountComponentFromNode(instance, container) {
286
+ ReactReconciler.unmountComponent(instance);
287
+
288
+ if (container.nodeType === DOC_NODE_TYPE) {
289
+ container = container.documentElement;
290
+ }
291
+
292
+ // http://jsperf.com/emptying-a-node
293
+ while (container.lastChild) {
294
+ container.removeChild(container.lastChild);
295
+ }
296
+ }
297
+
281
298
  /**
282
299
  * Mounting is the process of initializing a React component by creating its
283
300
  * representative DOM elements and inserting them into a supplied `container`.
@@ -308,7 +325,7 @@ var ReactMount = {
308
325
  * @param {DOMElement} container The `container` being rendered into.
309
326
  * @param {function} renderCallback This must be called once to do the render.
310
327
  */
311
- scrollMonitor: function(container, renderCallback) {
328
+ scrollMonitor: function (container, renderCallback) {
312
329
  renderCallback();
313
330
  },
314
331
 
@@ -319,26 +336,21 @@ var ReactMount = {
319
336
  * @param {DOMElement} container container to render into
320
337
  * @param {?function} callback function triggered on completion
321
338
  */
322
- _updateRootComponent: function(
323
- prevComponent,
324
- nextElement,
325
- container,
326
- callback) {
327
- if ("production" !== process.env.NODE_ENV) {
339
+ _updateRootComponent: function (prevComponent, nextElement, container, callback) {
340
+ if ('production' !== process.env.NODE_ENV) {
328
341
  ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
329
342
  }
330
343
 
331
- ReactMount.scrollMonitor(container, function() {
344
+ ReactMount.scrollMonitor(container, function () {
332
345
  ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
333
346
  if (callback) {
334
347
  ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
335
348
  }
336
349
  });
337
350
 
338
- if ("production" !== process.env.NODE_ENV) {
351
+ if ('production' !== process.env.NODE_ENV) {
339
352
  // Record the root element in case it later gets transplanted.
340
- rootElementsByReactRootID[getReactRootID(container)] =
341
- getReactRootElementInContainer(container);
353
+ rootElementsByReactRootID[getReactRootID(container)] = getReactRootElementInContainer(container);
342
354
  }
343
355
 
344
356
  return prevComponent;
@@ -351,15 +363,8 @@ var ReactMount = {
351
363
  * @param {DOMElement} container container to render into
352
364
  * @return {string} reactRoot ID prefix
353
365
  */
354
- _registerComponent: function(nextComponent, container) {
355
- ("production" !== process.env.NODE_ENV ? invariant(
356
- container && (
357
- (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
358
- ),
359
- '_registerComponent(...): Target container is not a DOM element.'
360
- ) : invariant(container && (
361
- (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
362
- )));
366
+ _registerComponent: function (nextComponent, container) {
367
+ 'production' !== process.env.NODE_ENV ? invariant(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE), '_registerComponent(...): Target container is not a DOM element.') : invariant(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE));
363
368
 
364
369
  ReactBrowserEventEmitter.ensureScrollValueMonitoring();
365
370
 
@@ -375,44 +380,24 @@ var ReactMount = {
375
380
  * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
376
381
  * @return {ReactComponent} nextComponent
377
382
  */
378
- _renderNewRootComponent: function(
379
- nextElement,
380
- container,
381
- shouldReuseMarkup
382
- ) {
383
+ _renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context) {
383
384
  // Various parts of our code (such as ReactCompositeComponent's
384
385
  // _renderValidatedComponent) assume that calls to render aren't nested;
385
386
  // verify that that's the case.
386
- ("production" !== process.env.NODE_ENV ? warning(
387
- ReactCurrentOwner.current == null,
388
- '_renderNewRootComponent(): Render methods should be a pure function ' +
389
- 'of props and state; triggering nested component updates from ' +
390
- 'render is not allowed. If necessary, trigger nested updates in ' +
391
- 'componentDidUpdate.'
392
- ) : null);
387
+ 'production' !== process.env.NODE_ENV ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : null;
393
388
 
394
389
  var componentInstance = instantiateReactComponent(nextElement, null);
395
- var reactRootID = ReactMount._registerComponent(
396
- componentInstance,
397
- container
398
- );
390
+ var reactRootID = ReactMount._registerComponent(componentInstance, container);
399
391
 
400
392
  // The initial render is synchronous but any updates that happen during
401
393
  // rendering, in componentWillMount or componentDidMount, will be batched
402
394
  // according to the current batching strategy.
403
395
 
404
- ReactUpdates.batchedUpdates(
405
- batchedMountComponentIntoNode,
406
- componentInstance,
407
- reactRootID,
408
- container,
409
- shouldReuseMarkup
410
- );
396
+ ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, reactRootID, container, shouldReuseMarkup, context);
411
397
 
412
- if ("production" !== process.env.NODE_ENV) {
398
+ if ('production' !== process.env.NODE_ENV) {
413
399
  // Record the root element in case it later gets transplanted.
414
- rootElementsByReactRootID[reactRootID] =
415
- getReactRootElementInContainer(container);
400
+ rootElementsByReactRootID[reactRootID] = getReactRootElementInContainer(container);
416
401
  }
417
402
 
418
403
  return componentInstance;
@@ -425,61 +410,44 @@ var ReactMount = {
425
410
  * perform an update on it and only mutate the DOM as necessary to reflect the
426
411
  * latest React component.
427
412
  *
413
+ * @param {ReactComponent} parentComponent The conceptual parent of this render tree.
428
414
  * @param {ReactElement} nextElement Component element to render.
429
415
  * @param {DOMElement} container DOM element to render into.
430
416
  * @param {?function} callback function triggered on completion
431
417
  * @return {ReactComponent} Component instance rendered in `container`.
432
418
  */
433
- render: function(nextElement, container, callback) {
434
- ("production" !== process.env.NODE_ENV ? invariant(
435
- ReactElement.isValidElement(nextElement),
436
- 'React.render(): Invalid component element.%s',
437
- (
438
- typeof nextElement === 'string' ?
439
- ' Instead of passing an element string, make sure to instantiate ' +
440
- 'it by passing it to React.createElement.' :
441
- typeof nextElement === 'function' ?
442
- ' Instead of passing a component class, make sure to instantiate ' +
443
- 'it by passing it to React.createElement.' :
444
- // Check if it quacks like an element
445
- nextElement != null && nextElement.props !== undefined ?
446
- ' This may be caused by unintentionally loading two independent ' +
447
- 'copies of React.' :
448
- ''
449
- )
450
- ) : invariant(ReactElement.isValidElement(nextElement)));
419
+ renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
420
+ 'production' !== process.env.NODE_ENV ? invariant(parentComponent != null && parentComponent._reactInternalInstance != null, 'parentComponent must be a valid React Component') : invariant(parentComponent != null && parentComponent._reactInternalInstance != null);
421
+ return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
422
+ },
423
+
424
+ _renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
425
+ 'production' !== process.env.NODE_ENV ? invariant(ReactElement.isValidElement(nextElement), 'React.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing an element string, make sure to instantiate ' + 'it by passing it to React.createElement.' : typeof nextElement === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' :
426
+ // Check if it quacks like an element
427
+ nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(ReactElement.isValidElement(nextElement));
428
+
429
+ 'production' !== process.env.NODE_ENV ? warning(container && container.tagName !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : null;
451
430
 
452
431
  var prevComponent = instancesByReactRootID[getReactRootID(container)];
453
432
 
454
433
  if (prevComponent) {
455
434
  var prevElement = prevComponent._currentElement;
456
435
  if (shouldUpdateReactComponent(prevElement, nextElement)) {
457
- return ReactMount._updateRootComponent(
458
- prevComponent,
459
- nextElement,
460
- container,
461
- callback
462
- ).getPublicInstance();
436
+ return ReactMount._updateRootComponent(prevComponent, nextElement, container, callback).getPublicInstance();
463
437
  } else {
464
438
  ReactMount.unmountComponentAtNode(container);
465
439
  }
466
440
  }
467
441
 
468
442
  var reactRootElement = getReactRootElementInContainer(container);
469
- var containerHasReactMarkup =
470
- reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
443
+ var containerHasReactMarkup = reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
471
444
 
472
- if ("production" !== process.env.NODE_ENV) {
445
+ if ('production' !== process.env.NODE_ENV) {
473
446
  if (!containerHasReactMarkup || reactRootElement.nextSibling) {
474
447
  var rootElementSibling = reactRootElement;
475
448
  while (rootElementSibling) {
476
449
  if (ReactMount.isRenderedByReact(rootElementSibling)) {
477
- ("production" !== process.env.NODE_ENV ? warning(
478
- false,
479
- 'render(): Target node has markup rendered by React, but there ' +
480
- 'are unrelated nodes as well. This is most commonly caused by ' +
481
- 'white-space inserted around server-rendered markup.'
482
- ) : null);
450
+ 'production' !== process.env.NODE_ENV ? warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.') : null;
483
451
  break;
484
452
  }
485
453
 
@@ -489,18 +457,29 @@ var ReactMount = {
489
457
  }
490
458
 
491
459
  var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
492
-
493
- var component = ReactMount._renderNewRootComponent(
494
- nextElement,
495
- container,
496
- shouldReuseMarkup
497
- ).getPublicInstance();
460
+ var component = ReactMount._renderNewRootComponent(nextElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject).getPublicInstance();
498
461
  if (callback) {
499
462
  callback.call(component);
500
463
  }
501
464
  return component;
502
465
  },
503
466
 
467
+ /**
468
+ * Renders a React component into the DOM in the supplied `container`.
469
+ *
470
+ * If the React component was previously rendered into `container`, this will
471
+ * perform an update on it and only mutate the DOM as necessary to reflect the
472
+ * latest React component.
473
+ *
474
+ * @param {ReactElement} nextElement Component element to render.
475
+ * @param {DOMElement} container DOM element to render into.
476
+ * @param {?function} callback function triggered on completion
477
+ * @return {ReactComponent} Component instance rendered in `container`.
478
+ */
479
+ render: function (nextElement, container, callback) {
480
+ return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
481
+ },
482
+
504
483
  /**
505
484
  * Constructs a component instance of `constructor` with `initialProps` and
506
485
  * renders it into the supplied `container`.
@@ -510,7 +489,7 @@ var ReactMount = {
510
489
  * @param {DOMElement} container DOM element to render into.
511
490
  * @return {ReactComponent} Component instance rendered in `container`.
512
491
  */
513
- constructAndRenderComponent: function(constructor, props, container) {
492
+ constructAndRenderComponent: function (constructor, props, container) {
514
493
  var element = ReactElement.createElement(constructor, props);
515
494
  return ReactMount.render(element, container);
516
495
  },
@@ -524,13 +503,9 @@ var ReactMount = {
524
503
  * @param {string} id ID of the DOM element to render into.
525
504
  * @return {ReactComponent} Component instance rendered in the container node.
526
505
  */
527
- constructAndRenderComponentByID: function(constructor, props, id) {
506
+ constructAndRenderComponentByID: function (constructor, props, id) {
528
507
  var domNode = document.getElementById(id);
529
- ("production" !== process.env.NODE_ENV ? invariant(
530
- domNode,
531
- 'Tried to get element with id of "%s" but it is not present on the page.',
532
- id
533
- ) : invariant(domNode));
508
+ 'production' !== process.env.NODE_ENV ? invariant(domNode, 'Tried to get element with id of "%s" but it is not present on the page.', id) : invariant(domNode);
534
509
  return ReactMount.constructAndRenderComponent(constructor, props, domNode);
535
510
  },
536
511
 
@@ -542,7 +517,7 @@ var ReactMount = {
542
517
  * @param {DOMElement} container DOM element to register as a container.
543
518
  * @return {string} The "reactRoot" ID of elements rendered within.
544
519
  */
545
- registerContainer: function(container) {
520
+ registerContainer: function (container) {
546
521
  var reactRootID = getReactRootID(container);
547
522
  if (reactRootID) {
548
523
  // If one exists, make sure it is a valid "reactRoot" ID.
@@ -563,64 +538,29 @@ var ReactMount = {
563
538
  * @return {boolean} True if a component was found in and unmounted from
564
539
  * `container`
565
540
  */
566
- unmountComponentAtNode: function(container) {
541
+ unmountComponentAtNode: function (container) {
567
542
  // Various parts of our code (such as ReactCompositeComponent's
568
543
  // _renderValidatedComponent) assume that calls to render aren't nested;
569
544
  // verify that that's the case. (Strictly speaking, unmounting won't cause a
570
545
  // render but we still don't expect to be in a render call here.)
571
- ("production" !== process.env.NODE_ENV ? warning(
572
- ReactCurrentOwner.current == null,
573
- 'unmountComponentAtNode(): Render methods should be a pure function of ' +
574
- 'props and state; triggering nested component updates from render is ' +
575
- 'not allowed. If necessary, trigger nested updates in ' +
576
- 'componentDidUpdate.'
577
- ) : null);
578
-
579
- ("production" !== process.env.NODE_ENV ? invariant(
580
- container && (
581
- (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
582
- ),
583
- 'unmountComponentAtNode(...): Target container is not a DOM element.'
584
- ) : invariant(container && (
585
- (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
586
- )));
546
+ 'production' !== process.env.NODE_ENV ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : null;
547
+
548
+ 'production' !== process.env.NODE_ENV ? invariant(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE), 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE));
587
549
 
588
550
  var reactRootID = getReactRootID(container);
589
551
  var component = instancesByReactRootID[reactRootID];
590
552
  if (!component) {
591
553
  return false;
592
554
  }
593
- ReactMount.unmountComponentFromNode(component, container);
555
+ ReactUpdates.batchedUpdates(unmountComponentFromNode, component, container);
594
556
  delete instancesByReactRootID[reactRootID];
595
557
  delete containersByReactRootID[reactRootID];
596
- if ("production" !== process.env.NODE_ENV) {
558
+ if ('production' !== process.env.NODE_ENV) {
597
559
  delete rootElementsByReactRootID[reactRootID];
598
560
  }
599
561
  return true;
600
562
  },
601
563
 
602
- /**
603
- * Unmounts a component and removes it from the DOM.
604
- *
605
- * @param {ReactComponent} instance React component instance.
606
- * @param {DOMElement} container DOM element to unmount from.
607
- * @final
608
- * @internal
609
- * @see {ReactMount.unmountComponentAtNode}
610
- */
611
- unmountComponentFromNode: function(instance, container) {
612
- ReactReconciler.unmountComponent(instance);
613
-
614
- if (container.nodeType === DOC_NODE_TYPE) {
615
- container = container.documentElement;
616
- }
617
-
618
- // http://jsperf.com/emptying-a-node
619
- while (container.lastChild) {
620
- container.removeChild(container.lastChild);
621
- }
622
- },
623
-
624
564
  /**
625
565
  * Finds the container DOM element that contains React component to which the
626
566
  * supplied DOM `id` belongs.
@@ -628,36 +568,26 @@ var ReactMount = {
628
568
  * @param {string} id The ID of an element rendered by a React component.
629
569
  * @return {?DOMElement} DOM element that contains the `id`.
630
570
  */
631
- findReactContainerForID: function(id) {
571
+ findReactContainerForID: function (id) {
632
572
  var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
633
573
  var container = containersByReactRootID[reactRootID];
634
574
 
635
- if ("production" !== process.env.NODE_ENV) {
575
+ if ('production' !== process.env.NODE_ENV) {
636
576
  var rootElement = rootElementsByReactRootID[reactRootID];
637
577
  if (rootElement && rootElement.parentNode !== container) {
638
- ("production" !== process.env.NODE_ENV ? invariant(
639
- // Call internalGetID here because getID calls isValid which calls
640
- // findReactContainerForID (this function).
641
- internalGetID(rootElement) === reactRootID,
642
- 'ReactMount: Root element ID differed from reactRootID.'
643
- ) : invariant(// Call internalGetID here because getID calls isValid which calls
578
+ 'production' !== process.env.NODE_ENV ? warning(
579
+ // Call internalGetID here because getID calls isValid which calls
644
580
  // findReactContainerForID (this function).
645
- internalGetID(rootElement) === reactRootID));
646
-
581
+ internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') : null;
647
582
  var containerChild = container.firstChild;
648
- if (containerChild &&
649
- reactRootID === internalGetID(containerChild)) {
583
+ if (containerChild && reactRootID === internalGetID(containerChild)) {
650
584
  // If the container has a new child with the same ID as the old
651
585
  // root element, then rootElementsByReactRootID[reactRootID] is
652
586
  // just stale and needs to be updated. The case that deserves a
653
587
  // warning is when the container is empty.
654
588
  rootElementsByReactRootID[reactRootID] = containerChild;
655
589
  } else {
656
- ("production" !== process.env.NODE_ENV ? warning(
657
- false,
658
- 'ReactMount: Root element has been removed from its original ' +
659
- 'container. New container:', rootElement.parentNode
660
- ) : null);
590
+ 'production' !== process.env.NODE_ENV ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container:', rootElement.parentNode) : null;
661
591
  }
662
592
  }
663
593
  }
@@ -671,7 +601,7 @@ var ReactMount = {
671
601
  * @param {string} id ID of a DOM node in the React component.
672
602
  * @return {DOMElement} Root DOM node of the React component.
673
603
  */
674
- findReactNodeByID: function(id) {
604
+ findReactNodeByID: function (id) {
675
605
  var reactRoot = ReactMount.findReactContainerForID(id);
676
606
  return ReactMount.findComponentRoot(reactRoot, id);
677
607
  },
@@ -683,7 +613,7 @@ var ReactMount = {
683
613
  * @return {boolean} True if the DOM Element appears to be rendered by React.
684
614
  * @internal
685
615
  */
686
- isRenderedByReact: function(node) {
616
+ isRenderedByReact: function (node) {
687
617
  if (node.nodeType !== 1) {
688
618
  // Not a DOMElement, therefore not a React component
689
619
  return false;
@@ -700,7 +630,7 @@ var ReactMount = {
700
630
  * @return {?DOMEventTarget}
701
631
  * @internal
702
632
  */
703
- getFirstReactDOM: function(node) {
633
+ getFirstReactDOM: function (node) {
704
634
  var current = node;
705
635
  while (current && current.parentNode !== current) {
706
636
  if (ReactMount.isRenderedByReact(current)) {
@@ -721,7 +651,7 @@ var ReactMount = {
721
651
  * @return {DOMEventTarget} DOM node with the supplied `targetID`.
722
652
  * @internal
723
653
  */
724
- findComponentRoot: function(ancestorNode, targetID) {
654
+ findComponentRoot: function (ancestorNode, targetID) {
725
655
  var firstChildren = findComponentRootReusableArray;
726
656
  var childIndex = 0;
727
657
 
@@ -752,7 +682,6 @@ var ReactMount = {
752
682
  firstChildren.length = childIndex = 0;
753
683
  firstChildren.push(child.firstChild);
754
684
  }
755
-
756
685
  } else {
757
686
  // If this child had no ID, then there's a chance that it was
758
687
  // injected automatically by the browser, as when a `<table>`
@@ -777,87 +706,35 @@ var ReactMount = {
777
706
 
778
707
  firstChildren.length = 0;
779
708
 
780
- ("production" !== process.env.NODE_ENV ? invariant(
781
- false,
782
- 'findComponentRoot(..., %s): Unable to find element. This probably ' +
783
- 'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
784
- 'usually due to forgetting a <tbody> when using tables, nesting tags ' +
785
- 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
786
- 'parent. ' +
787
- 'Try inspecting the child nodes of the element with React ID `%s`.',
788
- targetID,
789
- ReactMount.getID(ancestorNode)
790
- ) : invariant(false));
709
+ 'production' !== process.env.NODE_ENV ? invariant(false, 'findComponentRoot(..., %s): Unable to find element. This probably ' + 'means the DOM was unexpectedly mutated (e.g., by the browser), ' + 'usually due to forgetting a <tbody> when using tables, nesting tags ' + 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' + 'parent. ' + 'Try inspecting the child nodes of the element with React ID `%s`.', targetID, ReactMount.getID(ancestorNode)) : invariant(false);
791
710
  },
792
711
 
793
- _mountImageIntoNode: function(markup, container, shouldReuseMarkup) {
794
- ("production" !== process.env.NODE_ENV ? invariant(
795
- container && (
796
- (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
797
- ),
798
- 'mountComponentIntoNode(...): Target container is not valid.'
799
- ) : invariant(container && (
800
- (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
801
- )));
712
+ _mountImageIntoNode: function (markup, container, shouldReuseMarkup) {
713
+ 'production' !== process.env.NODE_ENV ? invariant(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE), 'mountComponentIntoNode(...): Target container is not valid.') : invariant(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE));
802
714
 
803
715
  if (shouldReuseMarkup) {
804
716
  var rootElement = getReactRootElementInContainer(container);
805
717
  if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
806
718
  return;
807
719
  } else {
808
- var checksum = rootElement.getAttribute(
809
- ReactMarkupChecksum.CHECKSUM_ATTR_NAME
810
- );
720
+ var checksum = rootElement.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
811
721
  rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
812
722
 
813
723
  var rootMarkup = rootElement.outerHTML;
814
- rootElement.setAttribute(
815
- ReactMarkupChecksum.CHECKSUM_ATTR_NAME,
816
- checksum
817
- );
724
+ rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum);
818
725
 
819
726
  var diffIndex = firstDifferenceIndex(markup, rootMarkup);
820
- var difference = ' (client) ' +
821
- markup.substring(diffIndex - 20, diffIndex + 20) +
822
- '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
823
-
824
- ("production" !== process.env.NODE_ENV ? invariant(
825
- container.nodeType !== DOC_NODE_TYPE,
826
- 'You\'re trying to render a component to the document using ' +
827
- 'server rendering but the checksum was invalid. This usually ' +
828
- 'means you rendered a different component type or props on ' +
829
- 'the client from the one on the server, or your render() ' +
830
- 'methods are impure. React cannot handle this case due to ' +
831
- 'cross-browser quirks by rendering at the document root. You ' +
832
- 'should look for environment dependent code in your components ' +
833
- 'and ensure the props are the same client and server side:\n%s',
834
- difference
835
- ) : invariant(container.nodeType !== DOC_NODE_TYPE));
836
-
837
- if ("production" !== process.env.NODE_ENV) {
838
- ("production" !== process.env.NODE_ENV ? warning(
839
- false,
840
- 'React attempted to reuse markup in a container but the ' +
841
- 'checksum was invalid. This generally means that you are ' +
842
- 'using server rendering and the markup generated on the ' +
843
- 'server was not what the client was expecting. React injected ' +
844
- 'new markup to compensate which works but you have lost many ' +
845
- 'of the benefits of server rendering. Instead, figure out ' +
846
- 'why the markup being generated is different on the client ' +
847
- 'or server:\n%s',
848
- difference
849
- ) : null);
727
+ var difference = ' (client) ' + markup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
728
+
729
+ 'production' !== process.env.NODE_ENV ? invariant(container.nodeType !== DOC_NODE_TYPE, 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + 'the client from the one on the server, or your render() ' + 'methods are impure. React cannot handle this case due to ' + 'cross-browser quirks by rendering at the document root. You ' + 'should look for environment dependent code in your components ' + 'and ensure the props are the same client and server side:\n%s', difference) : invariant(container.nodeType !== DOC_NODE_TYPE);
730
+
731
+ if ('production' !== process.env.NODE_ENV) {
732
+ 'production' !== process.env.NODE_ENV ? warning(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference) : null;
850
733
  }
851
734
  }
852
735
  }
853
736
 
854
- ("production" !== process.env.NODE_ENV ? invariant(
855
- container.nodeType !== DOC_NODE_TYPE,
856
- 'You\'re trying to render a component to the document but ' +
857
- 'you didn\'t use server rendering. We can\'t do this ' +
858
- 'without using server rendering due to cross-browser quirks. ' +
859
- 'See React.renderToString() for server rendering.'
860
- ) : invariant(container.nodeType !== DOC_NODE_TYPE));
737
+ 'production' !== process.env.NODE_ENV ? invariant(container.nodeType !== DOC_NODE_TYPE, 'You\'re trying to render a component to the document but ' + 'you didn\'t use server rendering. We can\'t do this ' + 'without using server rendering due to cross-browser quirks. ' + 'See React.renderToString() for server rendering.') : invariant(container.nodeType !== DOC_NODE_TYPE);
861
738
 
862
739
  setInnerHTML(container, markup);
863
740
  },
@@ -884,4 +761,4 @@ ReactPerf.measureMethods(ReactMount, 'ReactMount', {
884
761
  _mountImageIntoNode: '_mountImageIntoNode'
885
762
  });
886
763
 
887
- module.exports = ReactMount;
764
+ module.exports = ReactMount;