react 0.14.0-alpha3 → 0.14.0-rc1

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 (200) hide show
  1. package/README.md +5 -2
  2. package/addons.js +8 -3
  3. package/dist/react-dom.js +42 -0
  4. package/dist/react-dom.min.js +12 -0
  5. package/dist/react-with-addons.js +6076 -5337
  6. package/dist/react-with-addons.min.js +6 -6
  7. package/dist/react.js +5445 -4839
  8. package/dist/react.min.js +6 -5
  9. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
  10. package/lib/BeforeInputEventPlugin.js +13 -13
  11. package/lib/CSSProperty.js +18 -3
  12. package/lib/CSSPropertyOperations.js +22 -14
  13. package/lib/CallbackQueue.js +4 -4
  14. package/lib/ChangeEventPlugin.js +18 -15
  15. package/lib/DOMChildrenOperations.js +17 -7
  16. package/lib/DOMProperty.js +82 -117
  17. package/lib/DOMPropertyOperations.js +84 -33
  18. package/lib/Danger.js +21 -16
  19. package/lib/DefaultEventPluginOrder.js +2 -2
  20. package/lib/EnterLeaveEventPlugin.js +21 -13
  21. package/lib/EventConstants.js +23 -1
  22. package/lib/EventPluginHub.js +17 -20
  23. package/lib/EventPluginRegistry.js +8 -8
  24. package/lib/EventPluginUtils.js +33 -42
  25. package/lib/EventPropagators.js +8 -8
  26. package/lib/FallbackCompositionState.js +9 -3
  27. package/lib/HTMLDOMPropertyConfig.js +19 -3
  28. package/lib/LinkedStateMixin.js +2 -2
  29. package/lib/LinkedValueUtils.js +50 -38
  30. package/lib/MetaMatchers.js +118 -0
  31. package/lib/OrderedMap.js +453 -0
  32. package/lib/PooledClass.js +15 -5
  33. package/lib/React.js +18 -7
  34. package/lib/ReactBrowserComponentMixin.js +4 -4
  35. package/lib/ReactBrowserEventEmitter.js +30 -7
  36. package/lib/ReactCSSTransitionGroup.js +35 -9
  37. package/lib/ReactCSSTransitionGroupChild.js +56 -30
  38. package/lib/ReactChildReconciler.js +24 -19
  39. package/lib/ReactChildren.js +75 -35
  40. package/lib/ReactClass.js +70 -87
  41. package/lib/ReactComponent.js +27 -20
  42. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  43. package/lib/ReactComponentEnvironment.js +2 -2
  44. package/lib/ReactComponentWithPureRenderMixin.js +3 -3
  45. package/lib/ReactCompositeComponent.js +117 -106
  46. package/lib/ReactDOM.js +74 -158
  47. package/lib/ReactDOMButton.js +15 -26
  48. package/lib/ReactDOMComponent.js +441 -72
  49. package/lib/ReactDOMFactories.js +177 -0
  50. package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
  51. package/lib/ReactDOMIDOperations.js +8 -66
  52. package/lib/ReactDOMInput.js +87 -99
  53. package/lib/ReactDOMOption.js +25 -44
  54. package/lib/ReactDOMSelect.js +88 -98
  55. package/lib/ReactDOMSelection.js +3 -3
  56. package/lib/ReactDOMServer.js +5 -3
  57. package/lib/ReactDOMTextComponent.js +33 -20
  58. package/lib/ReactDOMTextarea.js +48 -61
  59. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  60. package/lib/ReactDefaultInjection.js +23 -72
  61. package/lib/ReactDefaultPerf.js +7 -7
  62. package/lib/ReactDefaultPerfAnalysis.js +6 -11
  63. package/lib/ReactElement.js +92 -107
  64. package/lib/ReactElementValidator.js +53 -173
  65. package/lib/ReactEmptyComponent.js +26 -62
  66. package/lib/ReactEmptyComponentRegistry.js +48 -0
  67. package/lib/ReactErrorUtils.js +45 -9
  68. package/lib/ReactEventEmitterMixin.js +3 -4
  69. package/lib/ReactEventListener.js +64 -12
  70. package/lib/ReactFragment.js +29 -115
  71. package/lib/ReactInjection.js +10 -12
  72. package/lib/ReactInputSelection.js +8 -7
  73. package/lib/ReactInstanceHandles.js +12 -12
  74. package/lib/ReactIsomorphic.js +15 -11
  75. package/lib/ReactLink.js +1 -1
  76. package/lib/ReactMarkupChecksum.js +6 -2
  77. package/lib/ReactMount.js +196 -122
  78. package/lib/ReactMultiChild.js +119 -25
  79. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  80. package/lib/ReactNativeComponent.js +3 -8
  81. package/lib/ReactNoopUpdateQueue.js +118 -0
  82. package/lib/ReactOwner.js +3 -3
  83. package/lib/ReactPerf.js +2 -2
  84. package/lib/ReactPropTransferer.js +3 -3
  85. package/lib/ReactPropTypeLocationNames.js +1 -1
  86. package/lib/ReactPropTypeLocations.js +1 -1
  87. package/lib/ReactPropTypes.js +41 -12
  88. package/lib/ReactReconcileTransaction.js +12 -10
  89. package/lib/ReactReconciler.js +8 -11
  90. package/lib/ReactRef.js +15 -2
  91. package/lib/ReactServerBatchingStrategy.js +23 -0
  92. package/lib/ReactServerRendering.js +22 -9
  93. package/lib/ReactServerRenderingTransaction.js +8 -7
  94. package/lib/ReactTestUtils.js +89 -64
  95. package/lib/ReactTransitionChildMapping.js +3 -6
  96. package/lib/ReactTransitionEvents.js +1 -1
  97. package/lib/ReactTransitionGroup.js +5 -6
  98. package/lib/ReactUpdateQueue.js +60 -35
  99. package/lib/ReactUpdates.js +15 -18
  100. package/lib/{isTextNode.js → ReactVersion.js} +2 -13
  101. package/lib/ReactWithAddons.js +24 -17
  102. package/lib/ResponderEventPlugin.js +514 -0
  103. package/lib/ResponderSyntheticEvent.js +40 -0
  104. package/lib/ResponderTouchHistoryStore.js +180 -0
  105. package/lib/SVGDOMPropertyConfig.js +1 -1
  106. package/lib/SelectEventPlugin.js +25 -16
  107. package/lib/SimpleEventPlugin.js +200 -45
  108. package/lib/SyntheticClipboardEvent.js +3 -3
  109. package/lib/SyntheticCompositionEvent.js +3 -3
  110. package/lib/SyntheticDragEvent.js +3 -3
  111. package/lib/SyntheticEvent.js +24 -8
  112. package/lib/SyntheticFocusEvent.js +3 -3
  113. package/lib/SyntheticInputEvent.js +3 -3
  114. package/lib/SyntheticKeyboardEvent.js +6 -6
  115. package/lib/SyntheticMouseEvent.js +5 -5
  116. package/lib/SyntheticTouchEvent.js +4 -4
  117. package/lib/SyntheticUIEvent.js +4 -4
  118. package/lib/SyntheticWheelEvent.js +3 -3
  119. package/lib/TapEventPlugin.js +119 -0
  120. package/lib/Transaction.js +17 -11
  121. package/lib/accumulate.js +44 -0
  122. package/lib/accumulateInto.js +2 -2
  123. package/lib/adler32.js +19 -7
  124. package/lib/cloneWithProps.js +12 -7
  125. package/lib/createHierarchyRenderer.js +85 -0
  126. package/lib/dangerousStyleValue.js +1 -1
  127. package/lib/deprecated.js +48 -0
  128. package/lib/findDOMNode.js +11 -12
  129. package/lib/flattenChildren.js +4 -4
  130. package/lib/forEachAccumulated.js +1 -1
  131. package/lib/getEventCharCode.js +1 -1
  132. package/lib/getEventKey.js +1 -1
  133. package/lib/getEventModifierState.js +0 -1
  134. package/lib/getTestDocument.js +28 -0
  135. package/lib/getTextContentAccessor.js +1 -1
  136. package/lib/instantiateReactComponent.js +27 -25
  137. package/lib/isEventSupported.js +1 -1
  138. package/lib/isTextInputElement.js +2 -1
  139. package/lib/joinClasses.js +1 -1
  140. package/lib/onlyChild.js +3 -3
  141. package/lib/quoteAttributeValueForBrowser.js +1 -1
  142. package/lib/reactComponentExpect.js +216 -0
  143. package/lib/renderSubtreeIntoContainer.js +1 -1
  144. package/lib/setInnerHTML.js +2 -2
  145. package/lib/setTextContent.js +3 -3
  146. package/lib/shallowCompare.js +1 -1
  147. package/lib/shouldUpdateReactComponent.js +12 -8
  148. package/lib/sliceChildren.js +34 -0
  149. package/lib/traverseAllChildren.js +21 -19
  150. package/lib/update.js +13 -13
  151. package/lib/validateDOMNesting.js +6 -6
  152. package/lib/webcomponents.js +6379 -0
  153. package/package.json +4 -6
  154. package/react.js +2 -0
  155. package/addons/CSSTransitionGroup.js +0 -1
  156. package/addons/LinkedStateMixin.js +0 -1
  157. package/addons/Perf.js +0 -1
  158. package/addons/PureRenderMixin.js +0 -1
  159. package/addons/TestUtils.js +0 -1
  160. package/addons/TransitionGroup.js +0 -1
  161. package/addons/batchedUpdates.js +0 -1
  162. package/addons/cloneWithProps.js +0 -1
  163. package/addons/createFragment.js +0 -1
  164. package/addons/renderSubtreeIntoContainer.js +0 -1
  165. package/addons/shallowCompare.js +0 -1
  166. package/addons/update.js +0 -1
  167. package/dist/JSXTransformer.js +0 -17589
  168. package/lib/CSSCore.js +0 -97
  169. package/lib/EventListener.js +0 -84
  170. package/lib/ExecutionEnvironment.js +0 -38
  171. package/lib/LocalEventTrapMixin.js +0 -46
  172. package/lib/ReactContext.js +0 -32
  173. package/lib/ReactDOMClient.js +0 -85
  174. package/lib/ReactDOMForm.js +0 -47
  175. package/lib/ReactDOMIframe.js +0 -43
  176. package/lib/ReactDOMImg.js +0 -44
  177. package/lib/ReactLifeCycle.js +0 -35
  178. package/lib/camelize.js +0 -32
  179. package/lib/camelizeStyleName.js +0 -40
  180. package/lib/containsNode.js +0 -55
  181. package/lib/createArrayFromMixed.js +0 -85
  182. package/lib/createFullPageComponent.js +0 -51
  183. package/lib/createNodesFromMarkup.js +0 -84
  184. package/lib/emptyFunction.js +0 -38
  185. package/lib/focusNode.js +0 -26
  186. package/lib/getActiveElement.js +0 -29
  187. package/lib/getMarkupWrap.js +0 -115
  188. package/lib/getUnboundedScrollPosition.js +0 -38
  189. package/lib/hyphenate.js +0 -33
  190. package/lib/hyphenateStyleName.js +0 -39
  191. package/lib/invariant.js +0 -49
  192. package/lib/isNode.js +0 -23
  193. package/lib/keyMirror.js +0 -48
  194. package/lib/keyOf.js +0 -35
  195. package/lib/mapObject.js +0 -51
  196. package/lib/performance.js +0 -23
  197. package/lib/performanceNow.js +0 -28
  198. package/lib/shallowEqual.js +0 -48
  199. package/lib/toArray.js +0 -57
  200. package/lib/warning.js +0 -61
@@ -12,9 +12,9 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var ReactRootIndex = require("./ReactRootIndex");
15
+ var ReactRootIndex = require('./ReactRootIndex');
16
16
 
17
- var invariant = require("./invariant");
17
+ var invariant = require('fbjs/lib/invariant');
18
18
 
19
19
  var SEPARATOR = '.';
20
20
  var SEPARATOR_LENGTH = SEPARATOR.length;
@@ -22,7 +22,7 @@ var SEPARATOR_LENGTH = SEPARATOR.length;
22
22
  /**
23
23
  * Maximum depth of traversals before we consider the possibility of a bad ID.
24
24
  */
25
- var MAX_TREE_DEPTH = 100;
25
+ var MAX_TREE_DEPTH = 10000;
26
26
 
27
27
  /**
28
28
  * Creates a DOM ID prefix to use when mounting React components.
@@ -91,8 +91,8 @@ function getParentID(id) {
91
91
  * @private
92
92
  */
93
93
  function getNextDescendantID(ancestorID, destinationID) {
94
- !(isValidID(ancestorID) && isValidID(destinationID)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : undefined;
95
- !isAncestorIDOf(ancestorID, destinationID) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : undefined;
94
+ !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : undefined;
95
+ !isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : undefined;
96
96
  if (ancestorID === destinationID) {
97
97
  return ancestorID;
98
98
  }
@@ -134,7 +134,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
134
134
  }
135
135
  }
136
136
  var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
137
- !isValidID(longestCommonID) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : undefined;
137
+ !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : undefined;
138
138
  return longestCommonID;
139
139
  }
140
140
 
@@ -146,6 +146,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
146
146
  * @param {?string} start ID at which to start traversal.
147
147
  * @param {?string} stop ID at which to end traversal.
148
148
  * @param {function} cb Callback to invoke each ID with.
149
+ * @param {*} arg Argument to invoke the callback with.
149
150
  * @param {?boolean} skipFirst Whether or not to skip the first node.
150
151
  * @param {?boolean} skipLast Whether or not to skip the last node.
151
152
  * @private
@@ -153,13 +154,13 @@ function getFirstCommonAncestorID(oneID, twoID) {
153
154
  function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
154
155
  start = start || '';
155
156
  stop = stop || '';
156
- !(start !== stop) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined;
157
+ !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined;
157
158
  var traverseUp = isAncestorIDOf(stop, start);
158
- !(traverseUp || isAncestorIDOf(start, stop)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : undefined;
159
+ !(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : undefined;
159
160
  // Traverse from `start` to `stop` one depth at a time.
160
161
  var depth = 0;
161
162
  var traverse = traverseUp ? getParentID : getNextDescendantID;
162
- for (var id = start;; id = traverse(id, stop)) {
163
+ for (var id = start;; /* until break */id = traverse(id, stop)) {
163
164
  var ret;
164
165
  if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
165
166
  ret = cb(id, traverseUp, arg);
@@ -168,7 +169,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
168
169
  // Only break //after// visiting `stop`.
169
170
  break;
170
171
  }
171
- !(depth++ < MAX_TREE_DEPTH) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop) : invariant(false) : undefined;
172
+ !(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : undefined;
172
173
  }
173
174
  }
174
175
 
@@ -298,5 +299,4 @@ var ReactInstanceHandles = {
298
299
 
299
300
  };
300
301
 
301
- module.exports = ReactInstanceHandles;
302
- /* until break */
302
+ module.exports = ReactInstanceHandles;
@@ -11,22 +11,23 @@
11
11
 
12
12
  'use strict';
13
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");
14
+ var ReactChildren = require('./ReactChildren');
15
+ var ReactComponent = require('./ReactComponent');
16
+ var ReactClass = require('./ReactClass');
17
+ var ReactDOMFactories = require('./ReactDOMFactories');
18
+ var ReactElement = require('./ReactElement');
19
+ var ReactElementValidator = require('./ReactElementValidator');
20
+ var ReactPropTypes = require('./ReactPropTypes');
21
+ var ReactVersion = require('./ReactVersion');
21
22
 
22
- var assign = require("./Object.assign");
23
- var onlyChild = require("./onlyChild");
23
+ var assign = require('./Object.assign');
24
+ var onlyChild = require('./onlyChild');
24
25
 
25
26
  var createElement = ReactElement.createElement;
26
27
  var createFactory = ReactElement.createFactory;
27
28
  var cloneElement = ReactElement.cloneElement;
28
29
 
29
- if ('production' !== process.env.NODE_ENV) {
30
+ if (process.env.NODE_ENV !== 'production') {
30
31
  createElement = ReactElementValidator.createElement;
31
32
  createFactory = ReactElementValidator.createFactory;
32
33
  cloneElement = ReactElementValidator.cloneElement;
@@ -40,6 +41,7 @@ var React = {
40
41
  map: ReactChildren.map,
41
42
  forEach: ReactChildren.forEach,
42
43
  count: ReactChildren.count,
44
+ toArray: ReactChildren.toArray,
43
45
  only: onlyChild
44
46
  },
45
47
 
@@ -61,7 +63,9 @@ var React = {
61
63
 
62
64
  // This looks DOM specific but these are actually isomorphic helpers
63
65
  // since they are just generating DOM strings.
64
- DOM: ReactDOM,
66
+ DOM: ReactDOMFactories,
67
+
68
+ version: ReactVersion,
65
69
 
66
70
  // Hook for JSX spread, don't use this for anything else.
67
71
  __spread: assign
package/lib/ReactLink.js CHANGED
@@ -35,7 +35,7 @@
35
35
  * consumption of ReactLink easier; see LinkedValueUtils and LinkedStateMixin.
36
36
  */
37
37
 
38
- var React = require("./React");
38
+ var React = require('./React');
39
39
 
40
40
  /**
41
41
  * @param {*} value current value of the link
@@ -11,7 +11,9 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var adler32 = require("./adler32");
14
+ var adler32 = require('./adler32');
15
+
16
+ var TAG_END = /\/?>/;
15
17
 
16
18
  var ReactMarkupChecksum = {
17
19
  CHECKSUM_ATTR_NAME: 'data-react-checksum',
@@ -22,7 +24,9 @@ var ReactMarkupChecksum = {
22
24
  */
23
25
  addChecksumToMarkup: function (markup) {
24
26
  var checksum = adler32(markup);
25
- return markup.replace('>', ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">');
27
+
28
+ // Add checksum (handle both parent tags and self-closing tags)
29
+ return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&');
26
30
  },
27
31
 
28
32
  /**
package/lib/ReactMount.js CHANGED
@@ -11,30 +11,29 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var DOMProperty = require("./DOMProperty");
15
- var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
16
- var ReactCurrentOwner = require("./ReactCurrentOwner");
17
- var ReactElement = require("./ReactElement");
18
- var ReactElementValidator = require("./ReactElementValidator");
19
- var ReactEmptyComponent = require("./ReactEmptyComponent");
20
- var ReactInstanceHandles = require("./ReactInstanceHandles");
21
- var ReactInstanceMap = require("./ReactInstanceMap");
22
- var ReactMarkupChecksum = require("./ReactMarkupChecksum");
23
- var ReactPerf = require("./ReactPerf");
24
- var ReactReconciler = require("./ReactReconciler");
25
- var ReactUpdateQueue = require("./ReactUpdateQueue");
26
- var ReactUpdates = require("./ReactUpdates");
27
-
28
- var emptyObject = require("./emptyObject");
29
- var containsNode = require("./containsNode");
30
- var instantiateReactComponent = require("./instantiateReactComponent");
31
- var invariant = require("./invariant");
32
- var setInnerHTML = require("./setInnerHTML");
33
- var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
34
- var validateDOMNesting = require("./validateDOMNesting");
35
- var warning = require("./warning");
36
-
37
- var SEPARATOR = ReactInstanceHandles.SEPARATOR;
14
+ var DOMProperty = require('./DOMProperty');
15
+ var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
16
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
17
+ var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
18
+ var ReactElement = require('./ReactElement');
19
+ var ReactEmptyComponentRegistry = require('./ReactEmptyComponentRegistry');
20
+ var ReactInstanceHandles = require('./ReactInstanceHandles');
21
+ var ReactInstanceMap = require('./ReactInstanceMap');
22
+ var ReactMarkupChecksum = require('./ReactMarkupChecksum');
23
+ var ReactPerf = require('./ReactPerf');
24
+ var ReactReconciler = require('./ReactReconciler');
25
+ var ReactUpdateQueue = require('./ReactUpdateQueue');
26
+ var ReactUpdates = require('./ReactUpdates');
27
+
28
+ var assign = require('./Object.assign');
29
+ var emptyObject = require('fbjs/lib/emptyObject');
30
+ var containsNode = require('fbjs/lib/containsNode');
31
+ var instantiateReactComponent = require('./instantiateReactComponent');
32
+ var invariant = require('fbjs/lib/invariant');
33
+ var setInnerHTML = require('./setInnerHTML');
34
+ var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
35
+ var validateDOMNesting = require('./validateDOMNesting');
36
+ var warning = require('fbjs/lib/warning');
38
37
 
39
38
  var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
40
39
  var nodeCache = {};
@@ -43,13 +42,15 @@ var ELEMENT_NODE_TYPE = 1;
43
42
  var DOC_NODE_TYPE = 9;
44
43
  var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
45
44
 
45
+ var ownerDocumentContextKey = '__ReactMount_ownerDocument$' + Math.random().toString(36).slice(2);
46
+
46
47
  /** Mapping from reactRootID to React component instance. */
47
48
  var instancesByReactRootID = {};
48
49
 
49
50
  /** Mapping from reactRootID to `container` nodes. */
50
51
  var containersByReactRootID = {};
51
52
 
52
- if ('production' !== process.env.NODE_ENV) {
53
+ if (process.env.NODE_ENV !== 'production') {
53
54
  /** __DEV__-only mapping from reactRootID to root elements. */
54
55
  var rootElementsByReactRootID = {};
55
56
  }
@@ -115,7 +116,7 @@ function getID(node) {
115
116
  if (nodeCache.hasOwnProperty(id)) {
116
117
  var cached = nodeCache[id];
117
118
  if (cached !== node) {
118
- !!isValid(cached, id) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(false) : undefined;
119
+ !!isValid(cached, id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(false) : undefined;
119
120
 
120
121
  nodeCache[id] = node;
121
122
  }
@@ -172,7 +173,7 @@ function getNode(id) {
172
173
  */
173
174
  function getNodeFromInstance(instance) {
174
175
  var id = ReactInstanceMap.get(instance)._rootNodeID;
175
- if (ReactEmptyComponent.isNullComponentID(id)) {
176
+ if (ReactEmptyComponentRegistry.isNullComponentID(id)) {
176
177
  return null;
177
178
  }
178
179
  if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
@@ -193,7 +194,7 @@ function getNodeFromInstance(instance) {
193
194
  */
194
195
  function isValid(node, id) {
195
196
  if (node) {
196
- !(internalGetID(node) === id) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined;
197
+ !(internalGetID(node) === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined;
197
198
 
198
199
  var container = ReactMount.findReactContainerForID(id);
199
200
  if (container && containsNode(container, node)) {
@@ -247,7 +248,15 @@ function findDeepestCachedAncestor(targetID) {
247
248
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
248
249
  */
249
250
  function mountComponentIntoNode(componentInstance, rootID, container, transaction, shouldReuseMarkup, context) {
250
- if ('production' !== process.env.NODE_ENV) {
251
+ if (ReactDOMFeatureFlags.useCreateElement) {
252
+ context = assign({}, context);
253
+ if (container.nodeType === DOC_NODE_TYPE) {
254
+ context[ownerDocumentContextKey] = container;
255
+ } else {
256
+ context[ownerDocumentContextKey] = container.ownerDocument;
257
+ }
258
+ }
259
+ if (process.env.NODE_ENV !== 'production') {
251
260
  if (context === emptyObject) {
252
261
  context = {};
253
262
  }
@@ -255,8 +264,8 @@ function mountComponentIntoNode(componentInstance, rootID, container, transactio
255
264
  context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
256
265
  }
257
266
  var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
258
- componentInstance._isTopLevel = true;
259
- ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
267
+ componentInstance._renderedComponent._topLevelWrapper = componentInstance;
268
+ ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup, transaction);
260
269
  }
261
270
 
262
271
  /**
@@ -268,7 +277,8 @@ function mountComponentIntoNode(componentInstance, rootID, container, transactio
268
277
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
269
278
  */
270
279
  function batchedMountComponentIntoNode(componentInstance, rootID, container, shouldReuseMarkup, context) {
271
- var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
280
+ var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
281
+ /* forceHTML */shouldReuseMarkup);
272
282
  transaction.perform(mountComponentIntoNode, null, componentInstance, rootID, container, transaction, shouldReuseMarkup, context);
273
283
  ReactUpdates.ReactReconcileTransaction.release(transaction);
274
284
  }
@@ -295,6 +305,73 @@ function unmountComponentFromNode(instance, container) {
295
305
  }
296
306
  }
297
307
 
308
+ /**
309
+ * True if the supplied DOM node has a direct React-rendered child that is
310
+ * not a React root element. Useful for warning in `render`,
311
+ * `unmountComponentAtNode`, etc.
312
+ *
313
+ * @param {?DOMElement} node The candidate DOM node.
314
+ * @return {boolean} True if the DOM element contains a direct child that was
315
+ * rendered by React but is not a root element.
316
+ * @internal
317
+ */
318
+ function hasNonRootReactChild(node) {
319
+ var reactRootID = getReactRootID(node);
320
+ return reactRootID ? reactRootID !== ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID) : false;
321
+ }
322
+
323
+ /**
324
+ * Returns the first (deepest) ancestor of a node which is rendered by this copy
325
+ * of React.
326
+ */
327
+ function findFirstReactDOMImpl(node) {
328
+ // This node might be from another React instance, so we make sure not to
329
+ // examine the node cache here
330
+ for (; node && node.parentNode !== node; node = node.parentNode) {
331
+ if (node.nodeType !== 1) {
332
+ // Not a DOMElement, therefore not a React component
333
+ continue;
334
+ }
335
+ var nodeID = internalGetID(node);
336
+ if (!nodeID) {
337
+ continue;
338
+ }
339
+ var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
340
+
341
+ // If containersByReactRootID contains the container we find by crawling up
342
+ // the tree, we know that this instance of React rendered the node.
343
+ // nb. isValid's strategy (with containsNode) does not work because render
344
+ // trees may be nested and we don't want a false positive in that case.
345
+ var current = node;
346
+ var lastID;
347
+ do {
348
+ lastID = internalGetID(current);
349
+ current = current.parentNode;
350
+ !(current != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findFirstReactDOMImpl(...): Unexpected detached subtree found when ' + 'traversing DOM from node `%s`.', nodeID) : invariant(false) : undefined;
351
+ } while (lastID !== reactRootID);
352
+
353
+ if (current === containersByReactRootID[reactRootID]) {
354
+ return node;
355
+ }
356
+ }
357
+ return null;
358
+ }
359
+
360
+ /**
361
+ * Temporary (?) hack so that we can store all top-level pending updates on
362
+ * composites instead of having to worry about different types of components
363
+ * here.
364
+ */
365
+ var TopLevelWrapper = function () {};
366
+ TopLevelWrapper.isReactClass = {};
367
+ if (process.env.NODE_ENV !== 'production') {
368
+ TopLevelWrapper.displayName = 'TopLevelWrapper';
369
+ }
370
+ TopLevelWrapper.prototype.render = function () {
371
+ // this.props is actually a ReactElement
372
+ return this.props;
373
+ };
374
+
298
375
  /**
299
376
  * Mounting is the process of initializing a React component by creating its
300
377
  * representative DOM elements and inserting them into a supplied `container`.
@@ -337,10 +414,6 @@ var ReactMount = {
337
414
  * @param {?function} callback function triggered on completion
338
415
  */
339
416
  _updateRootComponent: function (prevComponent, nextElement, container, callback) {
340
- if ('production' !== process.env.NODE_ENV) {
341
- ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
342
- }
343
-
344
417
  ReactMount.scrollMonitor(container, function () {
345
418
  ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
346
419
  if (callback) {
@@ -348,7 +421,7 @@ var ReactMount = {
348
421
  }
349
422
  });
350
423
 
351
- if ('production' !== process.env.NODE_ENV) {
424
+ if (process.env.NODE_ENV !== 'production') {
352
425
  // Record the root element in case it later gets transplanted.
353
426
  rootElementsByReactRootID[getReactRootID(container)] = getReactRootElementInContainer(container);
354
427
  }
@@ -364,7 +437,7 @@ var ReactMount = {
364
437
  * @return {string} reactRoot ID prefix
365
438
  */
366
439
  _registerComponent: function (nextComponent, container) {
367
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? 'production' !== process.env.NODE_ENV ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : undefined;
440
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : undefined;
368
441
 
369
442
  ReactBrowserEventEmitter.ensureScrollValueMonitoring();
370
443
 
@@ -384,7 +457,7 @@ var ReactMount = {
384
457
  // Various parts of our code (such as ReactCompositeComponent's
385
458
  // _renderValidatedComponent) assume that calls to render aren't nested;
386
459
  // verify that that's the case.
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') : undefined;
460
+ process.env.NODE_ENV !== 'production' ? 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') : undefined;
388
461
 
389
462
  var componentInstance = instantiateReactComponent(nextElement, null);
390
463
  var reactRootID = ReactMount._registerComponent(componentInstance, container);
@@ -395,7 +468,7 @@ var ReactMount = {
395
468
 
396
469
  ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, reactRootID, container, shouldReuseMarkup, context);
397
470
 
398
- if ('production' !== process.env.NODE_ENV) {
471
+ if (process.env.NODE_ENV !== 'production') {
399
472
  // Record the root element in case it later gets transplanted.
400
473
  rootElementsByReactRootID[reactRootID] = getReactRootElementInContainer(container);
401
474
  }
@@ -417,47 +490,52 @@ var ReactMount = {
417
490
  * @return {ReactComponent} Component instance rendered in `container`.
418
491
  */
419
492
  renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
420
- !(parentComponent != null && parentComponent._reactInternalInstance != null) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined;
493
+ !(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined;
421
494
  return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
422
495
  },
423
496
 
424
497
  _renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
425
- !ReactElement.isValidElement(nextElement) ? 'production' !== process.env.NODE_ENV ? invariant(false, '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.' :
498
+ !ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.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
499
  // Check if it quacks like an element
427
500
  nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : undefined;
428
501
 
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.') : undefined;
502
+ process.env.NODE_ENV !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== '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.') : undefined;
503
+
504
+ var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
430
505
 
431
506
  var prevComponent = instancesByReactRootID[getReactRootID(container)];
432
507
 
433
508
  if (prevComponent) {
434
- var prevElement = prevComponent._currentElement;
509
+ var prevWrappedElement = prevComponent._currentElement;
510
+ var prevElement = prevWrappedElement.props;
435
511
  if (shouldUpdateReactComponent(prevElement, nextElement)) {
436
- return ReactMount._updateRootComponent(prevComponent, nextElement, container, callback).getPublicInstance();
512
+ return ReactMount._updateRootComponent(prevComponent, nextWrappedElement, container, callback)._renderedComponent.getPublicInstance();
437
513
  } else {
438
514
  ReactMount.unmountComponentAtNode(container);
439
515
  }
440
516
  }
441
517
 
442
518
  var reactRootElement = getReactRootElementInContainer(container);
443
- var containerHasReactMarkup = reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
519
+ var containerHasReactMarkup = reactRootElement && !!internalGetID(reactRootElement);
520
+ var containerHasNonRootReactChild = hasNonRootReactChild(container);
521
+
522
+ if (process.env.NODE_ENV !== 'production') {
523
+ process.env.NODE_ENV !== 'production' ? warning(!containerHasNonRootReactChild, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : undefined;
444
524
 
445
- if ('production' !== process.env.NODE_ENV) {
446
525
  if (!containerHasReactMarkup || reactRootElement.nextSibling) {
447
526
  var rootElementSibling = reactRootElement;
448
527
  while (rootElementSibling) {
449
- if (ReactMount.isRenderedByReact(rootElementSibling)) {
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.') : undefined;
528
+ if (internalGetID(rootElementSibling)) {
529
+ process.env.NODE_ENV !== 'production' ? 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.') : undefined;
451
530
  break;
452
531
  }
453
-
454
532
  rootElementSibling = rootElementSibling.nextSibling;
455
533
  }
456
534
  }
457
535
  }
458
536
 
459
- var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
460
- var component = ReactMount._renderNewRootComponent(nextElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject).getPublicInstance();
537
+ var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild;
538
+ var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject)._renderedComponent.getPublicInstance();
461
539
  if (callback) {
462
540
  callback.call(component);
463
541
  }
@@ -480,35 +558,6 @@ var ReactMount = {
480
558
  return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
481
559
  },
482
560
 
483
- /**
484
- * Constructs a component instance of `constructor` with `initialProps` and
485
- * renders it into the supplied `container`.
486
- *
487
- * @param {function} constructor React component constructor.
488
- * @param {?object} props Initial props of the component instance.
489
- * @param {DOMElement} container DOM element to render into.
490
- * @return {ReactComponent} Component instance rendered in `container`.
491
- */
492
- constructAndRenderComponent: function (constructor, props, container) {
493
- var element = ReactElement.createElement(constructor, props);
494
- return ReactMount.render(element, container);
495
- },
496
-
497
- /**
498
- * Constructs a component instance of `constructor` with `initialProps` and
499
- * renders it into a container node identified by supplied `id`.
500
- *
501
- * @param {function} componentConstructor React component constructor
502
- * @param {?object} props Initial props of the component instance.
503
- * @param {string} id ID of the DOM element to render into.
504
- * @return {ReactComponent} Component instance rendered in the container node.
505
- */
506
- constructAndRenderComponentByID: function (constructor, props, id) {
507
- var domNode = document.getElementById(id);
508
- !domNode ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Tried to get element with id of "%s" but it is not present on the page.', id) : invariant(false) : undefined;
509
- return ReactMount.constructAndRenderComponent(constructor, props, domNode);
510
- },
511
-
512
561
  /**
513
562
  * Registers a container node into which React components will be rendered.
514
563
  * This also creates the "reactRoot" ID that will be assigned to the element
@@ -543,19 +592,31 @@ var ReactMount = {
543
592
  // _renderValidatedComponent) assume that calls to render aren't nested;
544
593
  // verify that that's the case. (Strictly speaking, unmounting won't cause a
545
594
  // render but we still don't expect to be in a render call here.)
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') : undefined;
595
+ process.env.NODE_ENV !== 'production' ? 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') : undefined;
547
596
 
548
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : undefined;
597
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : undefined;
549
598
 
550
599
  var reactRootID = getReactRootID(container);
551
600
  var component = instancesByReactRootID[reactRootID];
552
601
  if (!component) {
602
+ // Check if the node being unmounted was rendered by React, but isn't a
603
+ // root node.
604
+ var containerHasNonRootReactChild = hasNonRootReactChild(container);
605
+
606
+ // Check if the container itself is a React root node.
607
+ var containerID = internalGetID(container);
608
+ var isContainerReactRoot = containerID && containerID === ReactInstanceHandles.getReactRootIDFromNodeID(containerID);
609
+
610
+ if (process.env.NODE_ENV !== 'production') {
611
+ process.env.NODE_ENV !== 'production' ? warning(!containerHasNonRootReactChild, 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : undefined;
612
+ }
613
+
553
614
  return false;
554
615
  }
555
616
  ReactUpdates.batchedUpdates(unmountComponentFromNode, component, container);
556
617
  delete instancesByReactRootID[reactRootID];
557
618
  delete containersByReactRootID[reactRootID];
558
- if ('production' !== process.env.NODE_ENV) {
619
+ if (process.env.NODE_ENV !== 'production') {
559
620
  delete rootElementsByReactRootID[reactRootID];
560
621
  }
561
622
  return true;
@@ -572,10 +633,10 @@ var ReactMount = {
572
633
  var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
573
634
  var container = containersByReactRootID[reactRootID];
574
635
 
575
- if ('production' !== process.env.NODE_ENV) {
636
+ if (process.env.NODE_ENV !== 'production') {
576
637
  var rootElement = rootElementsByReactRootID[reactRootID];
577
638
  if (rootElement && rootElement.parentNode !== container) {
578
- 'production' !== process.env.NODE_ENV ? warning(
639
+ process.env.NODE_ENV !== 'production' ? warning(
579
640
  // Call internalGetID here because getID calls isValid which calls
580
641
  // findReactContainerForID (this function).
581
642
  internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') : undefined;
@@ -587,7 +648,7 @@ var ReactMount = {
587
648
  // warning is when the container is empty.
588
649
  rootElementsByReactRootID[reactRootID] = containerChild;
589
650
  } else {
590
- 'production' !== process.env.NODE_ENV ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container:', rootElement.parentNode) : undefined;
651
+ process.env.NODE_ENV !== 'production' ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined;
591
652
  }
592
653
  }
593
654
  }
@@ -606,39 +667,16 @@ var ReactMount = {
606
667
  return ReactMount.findComponentRoot(reactRoot, id);
607
668
  },
608
669
 
609
- /**
610
- * True if the supplied `node` is rendered by React.
611
- *
612
- * @param {*} node DOM Element to check.
613
- * @return {boolean} True if the DOM Element appears to be rendered by React.
614
- * @internal
615
- */
616
- isRenderedByReact: function (node) {
617
- if (node.nodeType !== 1) {
618
- // Not a DOMElement, therefore not a React component
619
- return false;
620
- }
621
- var id = ReactMount.getID(node);
622
- return id ? id.charAt(0) === SEPARATOR : false;
623
- },
624
-
625
670
  /**
626
671
  * Traverses up the ancestors of the supplied node to find a node that is a
627
- * DOM representation of a React component.
672
+ * DOM representation of a React component rendered by this copy of React.
628
673
  *
629
674
  * @param {*} node
630
675
  * @return {?DOMEventTarget}
631
676
  * @internal
632
677
  */
633
678
  getFirstReactDOM: function (node) {
634
- var current = node;
635
- while (current && current.parentNode !== current) {
636
- if (ReactMount.isRenderedByReact(current)) {
637
- return current;
638
- }
639
- current = current.parentNode;
640
- }
641
- return null;
679
+ return findFirstReactDOMImpl(node);
642
680
  },
643
681
 
644
682
  /**
@@ -657,6 +695,11 @@ var ReactMount = {
657
695
 
658
696
  var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
659
697
 
698
+ if (process.env.NODE_ENV !== 'production') {
699
+ // This will throw on the next line; give an early warning
700
+ process.env.NODE_ENV !== 'production' ? warning(deepestAncestor != null, 'React can\'t find the root component node for data-reactid value ' + '`%s`. If you\'re seeing this message, it probably means that ' + 'you\'ve loaded two copies of React on the page. At this time, only ' + 'a single copy of React can be loaded at a time.', targetID) : undefined;
701
+ }
702
+
660
703
  firstChildren[0] = deepestAncestor.firstChild;
661
704
  firstChildren.length = 1;
662
705
 
@@ -706,11 +749,11 @@ var ReactMount = {
706
749
 
707
750
  firstChildren.length = 0;
708
751
 
709
- !false ? '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) : undefined;
752
+ !false ? process.env.NODE_ENV !== 'production' ? 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) : undefined;
710
753
  },
711
754
 
712
- _mountImageIntoNode: function (markup, container, shouldReuseMarkup) {
713
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : undefined;
755
+ _mountImageIntoNode: function (markup, container, shouldReuseMarkup, transaction) {
756
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : undefined;
714
757
 
715
758
  if (shouldReuseMarkup) {
716
759
  var rootElement = getReactRootElementInContainer(container);
@@ -723,22 +766,51 @@ var ReactMount = {
723
766
  var rootMarkup = rootElement.outerHTML;
724
767
  rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum);
725
768
 
726
- var diffIndex = firstDifferenceIndex(markup, rootMarkup);
727
- var difference = ' (client) ' + markup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
769
+ var normalizedMarkup = markup;
770
+ if (process.env.NODE_ENV !== 'production') {
771
+ // because rootMarkup is retrieved from the DOM, various normalizations
772
+ // will have occurred which will not be present in `markup`. Here,
773
+ // insert markup into a <div> or <iframe> depending on the container
774
+ // type to perform the same normalizations before comparing.
775
+ var normalizer;
776
+ if (container.nodeType === ELEMENT_NODE_TYPE) {
777
+ normalizer = document.createElement('div');
778
+ normalizer.innerHTML = markup;
779
+ normalizedMarkup = normalizer.innerHTML;
780
+ } else {
781
+ normalizer = document.createElement('iframe');
782
+ document.body.appendChild(normalizer);
783
+ normalizer.contentDocument.write(markup);
784
+ normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
785
+ document.body.removeChild(normalizer);
786
+ }
787
+ }
728
788
 
729
- !(container.nodeType !== DOC_NODE_TYPE) ? 'production' !== process.env.NODE_ENV ? invariant(false, '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(false) : undefined;
789
+ var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
790
+ var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
730
791
 
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) : undefined;
792
+ !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, '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(false) : undefined;
793
+
794
+ if (process.env.NODE_ENV !== 'production') {
795
+ process.env.NODE_ENV !== 'production' ? 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) : undefined;
733
796
  }
734
797
  }
735
798
  }
736
799
 
737
- !(container.nodeType !== DOC_NODE_TYPE) ? 'production' !== process.env.NODE_ENV ? invariant(false, '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(false) : undefined;
800
+ !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, '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 ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
738
801
 
739
- setInnerHTML(container, markup);
802
+ if (transaction.useCreateElement) {
803
+ while (container.lastChild) {
804
+ container.removeChild(container.lastChild);
805
+ }
806
+ container.appendChild(markup);
807
+ } else {
808
+ setInnerHTML(container, markup);
809
+ }
740
810
  },
741
811
 
812
+ ownerDocumentContextKey: ownerDocumentContextKey,
813
+
742
814
  /**
743
815
  * React ID utilities.
744
816
  */
@@ -753,6 +825,8 @@ var ReactMount = {
753
825
 
754
826
  getNodeFromInstance: getNodeFromInstance,
755
827
 
828
+ isValid: isValid,
829
+
756
830
  purgeID: purgeID
757
831
  };
758
832