react 0.14.10 → 15.0.0

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 (193) hide show
  1. package/LICENSE +1 -1
  2. package/dist/react-with-addons.js +4900 -4627
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +4556 -4059
  5. package/dist/react.min.js +7 -7
  6. package/lib/AutoFocusUtils.js +3 -15
  7. package/lib/BeforeInputEventPlugin.js +8 -25
  8. package/lib/CSSProperty.js +10 -1
  9. package/lib/CSSPropertyOperations.js +49 -19
  10. package/lib/CallbackQueue.js +16 -4
  11. package/lib/ChangeEventPlugin.js +58 -54
  12. package/lib/DOMChildrenOperations.js +91 -61
  13. package/lib/DOMLazyTree.js +105 -0
  14. package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
  15. package/lib/DOMProperty.js +18 -39
  16. package/lib/DOMPropertyOperations.js +42 -53
  17. package/lib/Danger.js +13 -14
  18. package/lib/DefaultEventPluginOrder.js +1 -1
  19. package/lib/EnterLeaveEventPlugin.js +24 -43
  20. package/lib/EventConstants.js +6 -1
  21. package/lib/EventPluginHub.js +22 -66
  22. package/lib/EventPluginRegistry.js +30 -9
  23. package/lib/EventPluginUtils.js +61 -36
  24. package/lib/EventPropagators.js +19 -17
  25. package/lib/FallbackCompositionState.js +4 -4
  26. package/lib/HTMLDOMPropertyConfig.js +131 -152
  27. package/lib/LinkedStateMixin.js +1 -2
  28. package/lib/LinkedValueUtils.js +6 -7
  29. package/lib/MetaMatchers.js +2 -2
  30. package/lib/OrderedMap.js +17 -16
  31. package/lib/PooledClass.js +2 -2
  32. package/lib/React.js +50 -20
  33. package/lib/ReactBrowserEventEmitter.js +19 -26
  34. package/lib/ReactCSSTransitionGroup.js +4 -5
  35. package/lib/ReactCSSTransitionGroupChild.js +1 -6
  36. package/lib/ReactChildReconciler.js +15 -13
  37. package/lib/ReactChildren.js +5 -4
  38. package/lib/ReactClass.js +44 -92
  39. package/lib/ReactComponent.js +9 -10
  40. package/lib/ReactComponentBrowserEnvironment.js +9 -6
  41. package/lib/ReactComponentEnvironment.js +4 -4
  42. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  43. package/lib/ReactCompositeComponent.js +166 -74
  44. package/lib/ReactCurrentOwner.js +2 -1
  45. package/lib/ReactDOM.js +27 -15
  46. package/lib/ReactDOMButton.js +2 -2
  47. package/lib/ReactDOMComponent.js +186 -250
  48. package/lib/ReactDOMComponentFlags.js +18 -0
  49. package/lib/ReactDOMComponentTree.js +186 -0
  50. package/lib/ReactDOMContainerInfo.js +32 -0
  51. package/lib/ReactDOMDebugTool.js +61 -0
  52. package/lib/ReactDOMEmptyComponent.js +60 -0
  53. package/lib/ReactDOMFactories.js +1 -2
  54. package/lib/ReactDOMFeatureFlags.js +2 -2
  55. package/lib/ReactDOMIDOperations.js +5 -60
  56. package/lib/ReactDOMInput.js +73 -23
  57. package/lib/ReactDOMInstrumentation.js +16 -0
  58. package/lib/ReactDOMOption.js +14 -12
  59. package/lib/ReactDOMSelect.js +43 -19
  60. package/lib/ReactDOMSelection.js +4 -4
  61. package/lib/ReactDOMServer.js +1 -1
  62. package/lib/ReactDOMTextComponent.js +87 -45
  63. package/lib/ReactDOMTextarea.js +39 -11
  64. package/lib/ReactDOMTreeTraversal.js +134 -0
  65. package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
  66. package/lib/ReactDebugInstanceMap.js +102 -0
  67. package/lib/ReactDebugTool.js +72 -0
  68. package/lib/ReactDefaultBatchingStrategy.js +4 -3
  69. package/lib/ReactDefaultInjection.js +11 -15
  70. package/lib/ReactDefaultPerf.js +105 -26
  71. package/lib/ReactDefaultPerfAnalysis.js +23 -15
  72. package/lib/ReactElement.js +63 -23
  73. package/lib/ReactElementValidator.js +9 -9
  74. package/lib/ReactEmptyComponent.js +8 -33
  75. package/lib/ReactErrorUtils.js +1 -2
  76. package/lib/ReactEventEmitterMixin.js +3 -8
  77. package/lib/ReactEventListener.js +23 -77
  78. package/lib/ReactFeatureFlags.js +21 -0
  79. package/lib/ReactFragment.js +6 -6
  80. package/lib/ReactInjection.js +3 -3
  81. package/lib/ReactInputSelection.js +4 -4
  82. package/lib/ReactInstanceHandles.js +10 -12
  83. package/lib/ReactInstanceMap.js +2 -1
  84. package/lib/ReactInstrumentation.js +16 -0
  85. package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
  86. package/lib/ReactLink.js +2 -3
  87. package/lib/ReactMarkupChecksum.js +8 -3
  88. package/lib/ReactMount.js +88 -460
  89. package/lib/ReactMultiChild.js +106 -200
  90. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  91. package/lib/ReactNativeComponent.js +6 -5
  92. package/lib/ReactNodeTypes.js +37 -0
  93. package/lib/ReactNoopUpdateQueue.js +2 -25
  94. package/lib/ReactOwner.js +7 -6
  95. package/lib/ReactPerf.js +2 -2
  96. package/lib/ReactPropTransferer.js +5 -4
  97. package/lib/ReactPropTypeLocationNames.js +1 -1
  98. package/lib/ReactPropTypeLocations.js +1 -1
  99. package/lib/ReactPropTypes.js +31 -7
  100. package/lib/ReactReconcileTransaction.js +20 -9
  101. package/lib/ReactReconciler.js +29 -6
  102. package/lib/ReactRef.js +1 -1
  103. package/lib/ReactServerBatchingStrategy.js +1 -2
  104. package/lib/ReactServerRendering.js +17 -35
  105. package/lib/ReactServerRenderingTransaction.js +11 -29
  106. package/lib/ReactSimpleEmptyComponent.js +36 -0
  107. package/lib/ReactStateSetters.js +1 -1
  108. package/lib/ReactTestUtils.js +47 -28
  109. package/lib/ReactTransitionChildMapping.js +1 -2
  110. package/lib/ReactTransitionEvents.js +8 -44
  111. package/lib/ReactTransitionGroup.js +4 -3
  112. package/lib/ReactUMDEntry.js +26 -0
  113. package/lib/ReactUpdateQueue.js +24 -66
  114. package/lib/ReactUpdates.js +29 -11
  115. package/lib/ReactVersion.js +2 -2
  116. package/lib/ReactWithAddons.js +1 -21
  117. package/lib/ReactWithAddonsUMDEntry.js +26 -0
  118. package/lib/ResponderEventPlugin.js +54 -66
  119. package/lib/ResponderSyntheticEvent.js +2 -3
  120. package/lib/ResponderTouchHistoryStore.js +5 -5
  121. package/lib/SVGDOMPropertyConfig.js +267 -94
  122. package/lib/SelectEventPlugin.js +13 -18
  123. package/lib/SimpleEventPlugin.js +57 -17
  124. package/lib/SyntheticAnimationEvent.js +39 -0
  125. package/lib/SyntheticClipboardEvent.js +2 -3
  126. package/lib/SyntheticCompositionEvent.js +2 -3
  127. package/lib/SyntheticDragEvent.js +2 -3
  128. package/lib/SyntheticEvent.js +102 -21
  129. package/lib/SyntheticFocusEvent.js +2 -3
  130. package/lib/SyntheticInputEvent.js +2 -3
  131. package/lib/SyntheticKeyboardEvent.js +2 -3
  132. package/lib/SyntheticMouseEvent.js +2 -3
  133. package/lib/SyntheticTouchEvent.js +2 -3
  134. package/lib/SyntheticTransitionEvent.js +39 -0
  135. package/lib/SyntheticUIEvent.js +2 -3
  136. package/lib/SyntheticWheelEvent.js +2 -3
  137. package/lib/TapEventPlugin.js +3 -12
  138. package/lib/Transaction.js +3 -3
  139. package/lib/ViewportMetrics.js +1 -1
  140. package/lib/accumulate.js +2 -2
  141. package/lib/accumulateInto.js +2 -2
  142. package/lib/adler32.js +3 -2
  143. package/lib/canDefineProperty.js +1 -1
  144. package/lib/createHierarchyRenderer.js +1 -1
  145. package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
  146. package/lib/dangerousStyleValue.js +25 -3
  147. package/lib/deprecated.js +7 -4
  148. package/lib/escapeTextContentForBrowser.js +1 -1
  149. package/lib/findDOMNode.js +15 -8
  150. package/lib/flattenChildren.js +2 -2
  151. package/lib/forEachAccumulated.js +2 -1
  152. package/lib/getEventCharCode.js +2 -2
  153. package/lib/getEventKey.js +1 -2
  154. package/lib/getEventModifierState.js +1 -2
  155. package/lib/getEventTarget.js +8 -2
  156. package/lib/getIteratorFn.js +2 -2
  157. package/lib/getNativeComponentFromComposite.js +30 -0
  158. package/lib/getNodeForCharacterOffset.js +2 -1
  159. package/lib/getTestDocument.js +1 -1
  160. package/lib/getTextContentAccessor.js +1 -1
  161. package/lib/getVendorPrefixedEventName.js +101 -0
  162. package/lib/instantiateReactComponent.js +12 -13
  163. package/lib/isEventSupported.js +2 -2
  164. package/lib/isTextInputElement.js +2 -1
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/quoteAttributeValueForBrowser.js +1 -1
  167. package/lib/reactComponentExpect.js +5 -4
  168. package/lib/renderSubtreeIntoContainer.js +1 -1
  169. package/lib/setInnerHTML.js +6 -14
  170. package/lib/setTextContent.js +1 -1
  171. package/lib/shallowCompare.js +1 -1
  172. package/lib/shouldUpdateReactComponent.js +2 -3
  173. package/lib/sliceChildren.js +1 -1
  174. package/lib/traverseAllChildren.js +8 -8
  175. package/lib/update.js +16 -15
  176. package/lib/validateDOMNesting.js +18 -13
  177. package/package.json +23 -32
  178. package/addons.js +0 -13
  179. package/cjs/react-jsx-dev-runtime.development.js +0 -861
  180. package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
  181. package/cjs/react-jsx-runtime.development.js +0 -883
  182. package/cjs/react-jsx-runtime.production.min.js +0 -10
  183. package/jsx-dev-runtime.js +0 -7
  184. package/jsx-runtime.js +0 -7
  185. package/lib/Object.assign.js +0 -47
  186. package/lib/React.native.js +0 -5
  187. package/lib/ReactBrowserComponentMixin.js +0 -36
  188. package/lib/ReactEmptyComponentRegistry.js +0 -48
  189. package/lib/ReactIsomorphic.js +0 -74
  190. package/lib/ReactRootIndex.js +0 -29
  191. package/lib/ServerReactRootIndex.js +0 -29
  192. package/lib/cloneWithProps.js +0 -54
  193. package/lib/webcomponents.js +0 -6379
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright 2013-present, 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 ReactFeatureFlags
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactFeatureFlags = {
15
+ // When true, call console.time() before and .timeEnd() after each top-level
16
+ // render (both initial renders and updates). Useful when looking at prod-mode
17
+ // timeline profiles in Chrome, for example.
18
+ logTopLevelRenders: false
19
+ };
20
+
21
+ module.exports = ReactFeatureFlags;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2015, Facebook, Inc.
2
+ * Copyright 2015-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -20,7 +20,7 @@ var warning = require('fbjs/lib/warning');
20
20
 
21
21
  /**
22
22
  * We used to allow keyed objects to serve as a collection of ReactElements,
23
- * or nested sets. This allowed us a way to explicitly key a set a fragment of
23
+ * or nested sets. This allowed us a way to explicitly key a set or fragment of
24
24
  * components. This is now being replaced with an opaque data structure.
25
25
  * The upgrade path is to call React.addons.createFragment({ key: value }) to
26
26
  * create a keyed fragment. The resulting data structure is an array.
@@ -35,22 +35,22 @@ var ReactFragment = {
35
35
  // of its properties.
36
36
  create: function (object) {
37
37
  if (typeof object !== 'object' || !object || Array.isArray(object)) {
38
- process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : undefined;
38
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : void 0;
39
39
  return object;
40
40
  }
41
41
  if (ReactElement.isValidElement(object)) {
42
- process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : undefined;
42
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : void 0;
43
43
  return object;
44
44
  }
45
45
 
46
- !(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(false) : undefined;
46
+ !(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(false) : void 0;
47
47
 
48
48
  var result = [];
49
49
 
50
50
  for (var key in object) {
51
51
  if (process.env.NODE_ENV !== 'production') {
52
52
  if (!warnedAboutNumeric && numericPropertyRegex.test(key)) {
53
- process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment(...): Child objects should have ' + 'non-numeric keys so ordering is preserved.') : undefined;
53
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment(...): Child objects should have ' + 'non-numeric keys so ordering is preserved.') : void 0;
54
54
  warnedAboutNumeric = true;
55
55
  }
56
56
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -13,13 +13,13 @@
13
13
 
14
14
  var DOMProperty = require('./DOMProperty');
15
15
  var EventPluginHub = require('./EventPluginHub');
16
+ var EventPluginUtils = require('./EventPluginUtils');
16
17
  var ReactComponentEnvironment = require('./ReactComponentEnvironment');
17
18
  var ReactClass = require('./ReactClass');
18
19
  var ReactEmptyComponent = require('./ReactEmptyComponent');
19
20
  var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
20
21
  var ReactNativeComponent = require('./ReactNativeComponent');
21
22
  var ReactPerf = require('./ReactPerf');
22
- var ReactRootIndex = require('./ReactRootIndex');
23
23
  var ReactUpdates = require('./ReactUpdates');
24
24
 
25
25
  var ReactInjection = {
@@ -28,10 +28,10 @@ var ReactInjection = {
28
28
  DOMProperty: DOMProperty.injection,
29
29
  EmptyComponent: ReactEmptyComponent.injection,
30
30
  EventPluginHub: EventPluginHub.injection,
31
+ EventPluginUtils: EventPluginUtils.injection,
31
32
  EventEmitter: ReactBrowserEventEmitter.injection,
32
33
  NativeComponent: ReactNativeComponent.injection,
33
34
  Perf: ReactPerf.injection,
34
- RootIndex: ReactRootIndex.injection,
35
35
  Updates: ReactUpdates.injection
36
36
  };
37
37
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -74,7 +74,7 @@ var ReactInputSelection = {
74
74
  start: input.selectionStart,
75
75
  end: input.selectionEnd
76
76
  };
77
- } else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
77
+ } else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
78
78
  // IE8 input.
79
79
  var range = document.selection.createRange();
80
80
  // There can only be one selection per document in IE, so it must
@@ -102,14 +102,14 @@ var ReactInputSelection = {
102
102
  setSelection: function (input, offsets) {
103
103
  var start = offsets.start;
104
104
  var end = offsets.end;
105
- if (typeof end === 'undefined') {
105
+ if (end === undefined) {
106
106
  end = start;
107
107
  }
108
108
 
109
109
  if ('selectionStart' in input) {
110
110
  input.selectionStart = start;
111
111
  input.selectionEnd = Math.min(end, input.value.length);
112
- } else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
112
+ } else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
113
113
  var range = input.createTextRange();
114
114
  range.collapse(true);
115
115
  range.moveStart('character', start);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,13 +7,10 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactInstanceHandles
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
15
- var ReactRootIndex = require('./ReactRootIndex');
16
-
17
14
  var invariant = require('fbjs/lib/invariant');
18
15
 
19
16
  var SEPARATOR = '.';
@@ -91,8 +88,8 @@ function getParentID(id) {
91
88
  * @private
92
89
  */
93
90
  function getNextDescendantID(ancestorID, destinationID) {
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;
91
+ !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : void 0;
92
+ !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) : void 0;
96
93
  if (ancestorID === destinationID) {
97
94
  return ancestorID;
98
95
  }
@@ -134,7 +131,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
134
131
  }
135
132
  }
136
133
  var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
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;
134
+ !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : void 0;
138
135
  return longestCommonID;
139
136
  }
140
137
 
@@ -154,9 +151,9 @@ function getFirstCommonAncestorID(oneID, twoID) {
154
151
  function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
155
152
  start = start || '';
156
153
  stop = stop || '';
157
- !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined;
154
+ !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : void 0;
158
155
  var traverseUp = isAncestorIDOf(stop, start);
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;
156
+ !(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) : void 0;
160
157
  // Traverse from `start` to `stop` one depth at a time.
161
158
  var depth = 0;
162
159
  var traverse = traverseUp ? getParentID : getNextDescendantID;
@@ -169,7 +166,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
169
166
  // Only break //after// visiting `stop`.
170
167
  break;
171
168
  }
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;
169
+ !(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) : void 0;
173
170
  }
174
171
  }
175
172
 
@@ -184,10 +181,11 @@ var ReactInstanceHandles = {
184
181
 
185
182
  /**
186
183
  * Constructs a React root ID
184
+ * @param {number} index A unique integer
187
185
  * @return {string} A React root ID.
188
186
  */
189
- createReactRootID: function () {
190
- return getReactRootIDString(ReactRootIndex.createReactRootIndex());
187
+ createReactRootID: function (index) {
188
+ return getReactRootIDString(index);
191
189
  },
192
190
 
193
191
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -19,6 +19,7 @@
19
19
  */
20
20
 
21
21
  // TODO: Replace this with ES6: var ReactInstanceMap = new Map();
22
+
22
23
  var ReactInstanceMap = {
23
24
 
24
25
  /**
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2016-present, 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 ReactInstrumentation
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactDebugTool = require('./ReactDebugTool');
15
+
16
+ module.exports = { debugTool: ReactDebugTool };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright 2016-present, 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 ReactInvalidSetStateWarningDevTool
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var warning = require('fbjs/lib/warning');
15
+
16
+ if (process.env.NODE_ENV !== 'production') {
17
+ var processingChildContext = false;
18
+
19
+ var warnInvalidSetState = function () {
20
+ process.env.NODE_ENV !== 'production' ? warning(!processingChildContext, 'setState(...): Cannot call setState() inside getChildContext()') : void 0;
21
+ };
22
+ }
23
+
24
+ var ReactInvalidSetStateWarningDevTool = {
25
+ onBeginProcessingChildContext: function () {
26
+ processingChildContext = true;
27
+ },
28
+ onEndProcessingChildContext: function () {
29
+ processingChildContext = false;
30
+ },
31
+ onSetState: function () {
32
+ warnInvalidSetState();
33
+ }
34
+ };
35
+
36
+ module.exports = ReactInvalidSetStateWarningDevTool;
package/lib/ReactLink.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,7 +7,6 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactLink
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
@@ -56,7 +55,7 @@ function ReactLink(value, requestChange) {
56
55
  */
57
56
  function createLinkTypeChecker(linkType) {
58
57
  var shapes = {
59
- value: typeof linkType === 'undefined' ? React.PropTypes.any.isRequired : linkType.isRequired,
58
+ value: linkType === undefined ? React.PropTypes.any.isRequired : linkType.isRequired,
60
59
  requestChange: React.PropTypes.func.isRequired
61
60
  };
62
61
  return React.PropTypes.shape(shapes);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -14,6 +14,7 @@
14
14
  var adler32 = require('./adler32');
15
15
 
16
16
  var TAG_END = /\/?>/;
17
+ var COMMENT_START = /^<\!\-\-/;
17
18
 
18
19
  var ReactMarkupChecksum = {
19
20
  CHECKSUM_ATTR_NAME: 'data-react-checksum',
@@ -25,8 +26,12 @@ var ReactMarkupChecksum = {
25
26
  addChecksumToMarkup: function (markup) {
26
27
  var checksum = adler32(markup);
27
28
 
28
- // Add checksum (handle both parent tags and self-closing tags)
29
- return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&');
29
+ // Add checksum (handle both parent tags, comments and self-closing tags)
30
+ if (COMMENT_START.test(markup)) {
31
+ return markup;
32
+ } else {
33
+ return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&');
34
+ }
30
35
  },
31
36
 
32
37
  /**
package/lib/ReactMount.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -11,53 +11,38 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var DOMLazyTree = require('./DOMLazyTree');
14
15
  var DOMProperty = require('./DOMProperty');
15
16
  var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
16
17
  var ReactCurrentOwner = require('./ReactCurrentOwner');
18
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
19
+ var ReactDOMContainerInfo = require('./ReactDOMContainerInfo');
17
20
  var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
18
21
  var ReactElement = require('./ReactElement');
19
- var ReactEmptyComponentRegistry = require('./ReactEmptyComponentRegistry');
20
- var ReactInstanceHandles = require('./ReactInstanceHandles');
21
- var ReactInstanceMap = require('./ReactInstanceMap');
22
+ var ReactFeatureFlags = require('./ReactFeatureFlags');
23
+ var ReactInstrumentation = require('./ReactInstrumentation');
22
24
  var ReactMarkupChecksum = require('./ReactMarkupChecksum');
23
25
  var ReactPerf = require('./ReactPerf');
24
26
  var ReactReconciler = require('./ReactReconciler');
25
27
  var ReactUpdateQueue = require('./ReactUpdateQueue');
26
28
  var ReactUpdates = require('./ReactUpdates');
27
29
 
28
- var assign = require('./Object.assign');
29
30
  var emptyObject = require('fbjs/lib/emptyObject');
30
- var containsNode = require('fbjs/lib/containsNode');
31
31
  var instantiateReactComponent = require('./instantiateReactComponent');
32
32
  var invariant = require('fbjs/lib/invariant');
33
33
  var setInnerHTML = require('./setInnerHTML');
34
34
  var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
35
- var validateDOMNesting = require('./validateDOMNesting');
36
35
  var warning = require('fbjs/lib/warning');
37
36
 
38
37
  var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
39
- var nodeCache = {};
38
+ var ROOT_ATTR_NAME = DOMProperty.ROOT_ATTRIBUTE_NAME;
40
39
 
41
40
  var ELEMENT_NODE_TYPE = 1;
42
41
  var DOC_NODE_TYPE = 9;
43
42
  var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
44
43
 
45
- var ownerDocumentContextKey = '__ReactMount_ownerDocument$' + Math.random().toString(36).slice(2);
46
-
47
- /** Mapping from reactRootID to React component instance. */
48
44
  var instancesByReactRootID = {};
49
45
 
50
- /** Mapping from reactRootID to `container` nodes. */
51
- var containersByReactRootID = {};
52
-
53
- if (process.env.NODE_ENV !== 'production') {
54
- /** __DEV__-only mapping from reactRootID to root elements. */
55
- var rootElementsByReactRootID = {};
56
- }
57
-
58
- // Used to store breadth-first search state in findComponentRoot.
59
- var findComponentRootReusableArray = [];
60
-
61
46
  /**
62
47
  * Finds the index of the first character
63
48
  * that's not common between the two given strings.
@@ -91,195 +76,52 @@ function getReactRootElementInContainer(container) {
91
76
  }
92
77
  }
93
78
 
94
- /**
95
- * @param {DOMElement} container DOM element that may contain a React component.
96
- * @return {?string} A "reactRoot" ID, if a React component is rendered.
97
- */
98
- function getReactRootID(container) {
99
- var rootElement = getReactRootElementInContainer(container);
100
- return rootElement && ReactMount.getID(rootElement);
101
- }
102
-
103
- /**
104
- * Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
105
- * element can return its control whose name or ID equals ATTR_NAME. All
106
- * DOM nodes support `getAttributeNode` but this can also get called on
107
- * other objects so just return '' if we're given something other than a
108
- * DOM node (such as window).
109
- *
110
- * @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
111
- * @return {string} ID of the supplied `domNode`.
112
- */
113
- function getID(node) {
114
- var id = internalGetID(node);
115
- if (id) {
116
- if (nodeCache.hasOwnProperty(id)) {
117
- var cached = nodeCache[id];
118
- if (cached !== node) {
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;
120
-
121
- nodeCache[id] = node;
122
- }
123
- } else {
124
- nodeCache[id] = node;
125
- }
126
- }
127
-
128
- return id;
129
- }
130
-
131
79
  function internalGetID(node) {
132
80
  // If node is something like a window, document, or text node, none of
133
81
  // which support attributes or a .getAttribute method, gracefully return
134
82
  // the empty string, as if the attribute were missing.
135
- return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
136
- }
137
-
138
- /**
139
- * Sets the React-specific ID of the given node.
140
- *
141
- * @param {DOMElement} node The DOM node whose ID will be set.
142
- * @param {string} id The value of the ID attribute.
143
- */
144
- function setID(node, id) {
145
- var oldID = internalGetID(node);
146
- if (oldID !== id) {
147
- delete nodeCache[oldID];
148
- }
149
- node.setAttribute(ATTR_NAME, id);
150
- nodeCache[id] = node;
151
- }
152
-
153
- /**
154
- * Finds the node with the supplied React-generated DOM ID.
155
- *
156
- * @param {string} id A React-generated DOM ID.
157
- * @return {DOMElement} DOM node with the suppled `id`.
158
- * @internal
159
- */
160
- function getNode(id) {
161
- if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
162
- nodeCache[id] = ReactMount.findReactNodeByID(id);
163
- }
164
- return nodeCache[id];
165
- }
166
-
167
- /**
168
- * Finds the node with the supplied public React instance.
169
- *
170
- * @param {*} instance A public React instance.
171
- * @return {?DOMElement} DOM node with the suppled `id`.
172
- * @internal
173
- */
174
- function getNodeFromInstance(instance) {
175
- var id = ReactInstanceMap.get(instance)._rootNodeID;
176
- if (ReactEmptyComponentRegistry.isNullComponentID(id)) {
177
- return null;
178
- }
179
- if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
180
- nodeCache[id] = ReactMount.findReactNodeByID(id);
181
- }
182
- return nodeCache[id];
183
- }
184
-
185
- /**
186
- * A node is "valid" if it is contained by a currently mounted container.
187
- *
188
- * This means that the node does not have to be contained by a document in
189
- * order to be considered valid.
190
- *
191
- * @param {?DOMElement} node The candidate DOM node.
192
- * @param {string} id The expected ID of the node.
193
- * @return {boolean} Whether the node is contained by a mounted container.
194
- */
195
- function isValid(node, id) {
196
- if (node) {
197
- !(internalGetID(node) === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined;
198
-
199
- var container = ReactMount.findReactContainerForID(id);
200
- if (container && containsNode(container, node)) {
201
- return true;
202
- }
203
- }
204
-
205
- return false;
206
- }
207
-
208
- /**
209
- * Causes the cache to forget about one React-specific ID.
210
- *
211
- * @param {string} id The ID to forget.
212
- */
213
- function purgeID(id) {
214
- delete nodeCache[id];
215
- }
216
-
217
- var deepestNodeSoFar = null;
218
- function findDeepestCachedAncestorImpl(ancestorID) {
219
- var ancestor = nodeCache[ancestorID];
220
- if (ancestor && isValid(ancestor, ancestorID)) {
221
- deepestNodeSoFar = ancestor;
222
- } else {
223
- // This node isn't populated in the cache, so presumably none of its
224
- // descendants are. Break out of the loop.
225
- return false;
226
- }
227
- }
228
-
229
- /**
230
- * Return the deepest cached node whose ID is a prefix of `targetID`.
231
- */
232
- function findDeepestCachedAncestor(targetID) {
233
- deepestNodeSoFar = null;
234
- ReactInstanceHandles.traverseAncestors(targetID, findDeepestCachedAncestorImpl);
235
-
236
- var foundNode = deepestNodeSoFar;
237
- deepestNodeSoFar = null;
238
- return foundNode;
83
+ return node.getAttribute && node.getAttribute(ATTR_NAME) || '';
239
84
  }
240
85
 
241
86
  /**
242
87
  * Mounts this component and inserts it into the DOM.
243
88
  *
244
89
  * @param {ReactComponent} componentInstance The instance to mount.
245
- * @param {string} rootID DOM ID of the root node.
246
90
  * @param {DOMElement} container DOM element to mount into.
247
91
  * @param {ReactReconcileTransaction} transaction
248
92
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
249
93
  */
250
- function mountComponentIntoNode(componentInstance, rootID, container, transaction, shouldReuseMarkup, context) {
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
- }
94
+ function mountComponentIntoNode(wrapperInstance, container, transaction, shouldReuseMarkup, context) {
95
+ var markerName;
96
+ if (ReactFeatureFlags.logTopLevelRenders) {
97
+ var wrappedElement = wrapperInstance._currentElement.props;
98
+ var type = wrappedElement.type;
99
+ markerName = 'React mount: ' + (typeof type === 'string' ? type : type.displayName || type.name);
100
+ console.time(markerName);
258
101
  }
259
- if (process.env.NODE_ENV !== 'production') {
260
- if (context === emptyObject) {
261
- context = {};
262
- }
263
- var tag = container.nodeName.toLowerCase();
264
- context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
102
+
103
+ var markup = ReactReconciler.mountComponent(wrapperInstance, transaction, null, ReactDOMContainerInfo(wrapperInstance, container), context);
104
+
105
+ if (markerName) {
106
+ console.timeEnd(markerName);
265
107
  }
266
- var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
267
- componentInstance._renderedComponent._topLevelWrapper = componentInstance;
268
- ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup, transaction);
108
+
109
+ wrapperInstance._renderedComponent._topLevelWrapper = wrapperInstance;
110
+ ReactMount._mountImageIntoNode(markup, container, wrapperInstance, shouldReuseMarkup, transaction);
269
111
  }
270
112
 
271
113
  /**
272
114
  * Batched mount.
273
115
  *
274
116
  * @param {ReactComponent} componentInstance The instance to mount.
275
- * @param {string} rootID DOM ID of the root node.
276
117
  * @param {DOMElement} container DOM element to mount into.
277
118
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
278
119
  */
279
- function batchedMountComponentIntoNode(componentInstance, rootID, container, shouldReuseMarkup, context) {
120
+ function batchedMountComponentIntoNode(componentInstance, container, shouldReuseMarkup, context) {
280
121
  var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
281
- /* forceHTML */shouldReuseMarkup);
282
- transaction.perform(mountComponentIntoNode, null, componentInstance, rootID, container, transaction, shouldReuseMarkup, context);
122
+ /* useCreateElement */
123
+ !shouldReuseMarkup && ReactDOMFeatureFlags.useCreateElement);
124
+ transaction.perform(mountComponentIntoNode, null, componentInstance, container, transaction, shouldReuseMarkup, context);
283
125
  ReactUpdates.ReactReconcileTransaction.release(transaction);
284
126
  }
285
127
 
@@ -292,8 +134,8 @@ function batchedMountComponentIntoNode(componentInstance, rootID, container, sho
292
134
  * @internal
293
135
  * @see {ReactMount.unmountComponentAtNode}
294
136
  */
295
- function unmountComponentFromNode(instance, container) {
296
- ReactReconciler.unmountComponent(instance);
137
+ function unmountComponentFromNode(instance, container, safely) {
138
+ ReactReconciler.unmountComponent(instance, safely);
297
139
 
298
140
  if (container.nodeType === DOC_NODE_TYPE) {
299
141
  container = container.documentElement;
@@ -315,50 +157,23 @@ function unmountComponentFromNode(instance, container) {
315
157
  * rendered by React but is not a root element.
316
158
  * @internal
317
159
  */
318
- function hasNonRootReactChild(node) {
319
- var reactRootID = getReactRootID(node);
320
- return reactRootID ? reactRootID !== ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID) : false;
160
+ function hasNonRootReactChild(container) {
161
+ var rootEl = getReactRootElementInContainer(container);
162
+ if (rootEl) {
163
+ var inst = ReactDOMComponentTree.getInstanceFromNode(rootEl);
164
+ return !!(inst && inst._nativeParent);
165
+ }
321
166
  }
322
167
 
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
- if (current == null) {
351
- // The passed-in node has been detached from the container it was
352
- // originally rendered into.
353
- return null;
354
- }
355
- } while (lastID !== reactRootID);
168
+ function getNativeRootInstanceInContainer(container) {
169
+ var rootEl = getReactRootElementInContainer(container);
170
+ var prevNativeInstance = rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl);
171
+ return prevNativeInstance && !prevNativeInstance._nativeParent ? prevNativeInstance : null;
172
+ }
356
173
 
357
- if (current === containersByReactRootID[reactRootID]) {
358
- return node;
359
- }
360
- }
361
- return null;
174
+ function getTopLevelWrapperInContainer(container) {
175
+ var root = getNativeRootInstanceInContainer(container);
176
+ return root ? root._nativeContainerInfo._topLevelWrapper : null;
362
177
  }
363
178
 
364
179
  /**
@@ -366,7 +181,10 @@ function findFirstReactDOMImpl(node) {
366
181
  * composites instead of having to worry about different types of components
367
182
  * here.
368
183
  */
369
- var TopLevelWrapper = function () {};
184
+ var topLevelRootCounter = 1;
185
+ var TopLevelWrapper = function () {
186
+ this.rootID = topLevelRootCounter++;
187
+ };
370
188
  TopLevelWrapper.prototype.isReactComponent = {};
371
189
  if (process.env.NODE_ENV !== 'production') {
372
190
  TopLevelWrapper.displayName = 'TopLevelWrapper';
@@ -398,7 +216,9 @@ var ReactMount = {
398
216
 
399
217
  TopLevelWrapper: TopLevelWrapper,
400
218
 
401
- /** Exposed for debugging purposes **/
219
+ /**
220
+ * Used by devtools. The keys are not important.
221
+ */
402
222
  _instancesByReactRootID: instancesByReactRootID,
403
223
 
404
224
  /**
@@ -428,33 +248,12 @@ var ReactMount = {
428
248
  }
429
249
  });
430
250
 
431
- if (process.env.NODE_ENV !== 'production') {
432
- // Record the root element in case it later gets transplanted.
433
- rootElementsByReactRootID[getReactRootID(container)] = getReactRootElementInContainer(container);
434
- }
435
-
436
251
  return prevComponent;
437
252
  },
438
253
 
439
254
  /**
440
- * Register a component into the instance map and starts scroll value
441
- * monitoring
442
- * @param {ReactComponent} nextComponent component instance to render
443
- * @param {DOMElement} container container to render into
444
- * @return {string} reactRoot ID prefix
445
- */
446
- _registerComponent: function (nextComponent, container) {
447
- !(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;
448
-
449
- ReactBrowserEventEmitter.ensureScrollValueMonitoring();
450
-
451
- var reactRootID = ReactMount.registerContainer(container);
452
- instancesByReactRootID[reactRootID] = nextComponent;
453
- return reactRootID;
454
- },
455
-
456
- /**
457
- * Render a new component into the DOM.
255
+ * Render a new component into the DOM. Hooked by devtools!
256
+ *
458
257
  * @param {ReactElement} nextElement element to render
459
258
  * @param {DOMElement} container container to render into
460
259
  * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
@@ -464,20 +263,24 @@ var ReactMount = {
464
263
  // Various parts of our code (such as ReactCompositeComponent's
465
264
  // _renderValidatedComponent) assume that calls to render aren't nested;
466
265
  // verify that that's the case.
467
- 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;
266
+ 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') : void 0;
267
+
268
+ !(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) : void 0;
468
269
 
469
- var componentInstance = instantiateReactComponent(nextElement, null);
470
- var reactRootID = ReactMount._registerComponent(componentInstance, container);
270
+ ReactBrowserEventEmitter.ensureScrollValueMonitoring();
271
+ var componentInstance = instantiateReactComponent(nextElement);
471
272
 
472
273
  // The initial render is synchronous but any updates that happen during
473
274
  // rendering, in componentWillMount or componentDidMount, will be batched
474
275
  // according to the current batching strategy.
475
276
 
476
- ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, reactRootID, container, shouldReuseMarkup, context);
277
+ ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, container, shouldReuseMarkup, context);
278
+
279
+ var wrapperID = componentInstance._instance.rootID;
280
+ instancesByReactRootID[wrapperID] = componentInstance;
477
281
 
478
282
  if (process.env.NODE_ENV !== 'production') {
479
- // Record the root element in case it later gets transplanted.
480
- rootElementsByReactRootID[reactRootID] = getReactRootElementInContainer(container);
283
+ ReactInstrumentation.debugTool.onMountRootComponent(componentInstance);
481
284
  }
482
285
 
483
286
  return componentInstance;
@@ -497,20 +300,21 @@ var ReactMount = {
497
300
  * @return {ReactComponent} Component instance rendered in `container`.
498
301
  */
499
302
  renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
500
- !(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined;
303
+ !(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : void 0;
501
304
  return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
502
305
  },
503
306
 
504
307
  _renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
505
- !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.' :
308
+ ReactUpdateQueue.validateCallback(callback, 'ReactDOM.render');
309
+ !ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.' : typeof nextElement === 'function' ? ' Instead of passing a class like Foo, pass ' + 'React.createElement(Foo) or <Foo />.' :
506
310
  // Check if it quacks like an element
507
- nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : undefined;
311
+ nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : void 0;
508
312
 
509
- 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;
313
+ 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.') : void 0;
510
314
 
511
- var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
315
+ var nextWrappedElement = ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
512
316
 
513
- var prevComponent = instancesByReactRootID[getReactRootID(container)];
317
+ var prevComponent = getTopLevelWrapperInContainer(container);
514
318
 
515
319
  if (prevComponent) {
516
320
  var prevWrappedElement = prevComponent._currentElement;
@@ -532,13 +336,13 @@ var ReactMount = {
532
336
  var containerHasNonRootReactChild = hasNonRootReactChild(container);
533
337
 
534
338
  if (process.env.NODE_ENV !== 'production') {
535
- 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;
339
+ 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.') : void 0;
536
340
 
537
341
  if (!containerHasReactMarkup || reactRootElement.nextSibling) {
538
342
  var rootElementSibling = reactRootElement;
539
343
  while (rootElementSibling) {
540
344
  if (internalGetID(rootElementSibling)) {
541
- 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;
345
+ 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.') : void 0;
542
346
  break;
543
347
  }
544
348
  rootElementSibling = rootElementSibling.nextSibling;
@@ -570,28 +374,6 @@ var ReactMount = {
570
374
  return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
571
375
  },
572
376
 
573
- /**
574
- * Registers a container node into which React components will be rendered.
575
- * This also creates the "reactRoot" ID that will be assigned to the element
576
- * rendered within.
577
- *
578
- * @param {DOMElement} container DOM element to register as a container.
579
- * @return {string} The "reactRoot" ID of elements rendered within.
580
- */
581
- registerContainer: function (container) {
582
- var reactRootID = getReactRootID(container);
583
- if (reactRootID) {
584
- // If one exists, make sure it is a valid "reactRoot" ID.
585
- reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
586
- }
587
- if (!reactRootID) {
588
- // No valid "reactRoot" ID found, create one.
589
- reactRootID = ReactInstanceHandles.createReactRootID();
590
- }
591
- containersByReactRootID[reactRootID] = container;
592
- return reactRootID;
593
- },
594
-
595
377
  /**
596
378
  * Unmounts and destroys the React component rendered in the `container`.
597
379
  *
@@ -604,172 +386,37 @@ var ReactMount = {
604
386
  // _renderValidatedComponent) assume that calls to render aren't nested;
605
387
  // verify that that's the case. (Strictly speaking, unmounting won't cause a
606
388
  // render but we still don't expect to be in a render call here.)
607
- 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;
389
+ 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') : void 0;
608
390
 
609
- !(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;
391
+ !(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) : void 0;
610
392
 
611
- var reactRootID = getReactRootID(container);
612
- var component = instancesByReactRootID[reactRootID];
613
- if (!component) {
393
+ var prevComponent = getTopLevelWrapperInContainer(container);
394
+ if (!prevComponent) {
614
395
  // Check if the node being unmounted was rendered by React, but isn't a
615
396
  // root node.
616
397
  var containerHasNonRootReactChild = hasNonRootReactChild(container);
617
398
 
618
399
  // Check if the container itself is a React root node.
619
- var containerID = internalGetID(container);
620
- var isContainerReactRoot = containerID && containerID === ReactInstanceHandles.getReactRootIDFromNodeID(containerID);
400
+ var isContainerReactRoot = container.nodeType === 1 && container.hasAttribute(ROOT_ATTR_NAME);
621
401
 
622
402
  if (process.env.NODE_ENV !== 'production') {
623
- 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;
403
+ 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.') : void 0;
624
404
  }
625
405
 
626
406
  return false;
627
407
  }
628
- ReactUpdates.batchedUpdates(unmountComponentFromNode, component, container);
629
- delete instancesByReactRootID[reactRootID];
630
- delete containersByReactRootID[reactRootID];
631
- if (process.env.NODE_ENV !== 'production') {
632
- delete rootElementsByReactRootID[reactRootID];
633
- }
408
+ delete instancesByReactRootID[prevComponent._instance.rootID];
409
+ ReactUpdates.batchedUpdates(unmountComponentFromNode, prevComponent, container, false);
634
410
  return true;
635
411
  },
636
412
 
637
- /**
638
- * Finds the container DOM element that contains React component to which the
639
- * supplied DOM `id` belongs.
640
- *
641
- * @param {string} id The ID of an element rendered by a React component.
642
- * @return {?DOMElement} DOM element that contains the `id`.
643
- */
644
- findReactContainerForID: function (id) {
645
- var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
646
- var container = containersByReactRootID[reactRootID];
647
-
648
- if (process.env.NODE_ENV !== 'production') {
649
- var rootElement = rootElementsByReactRootID[reactRootID];
650
- if (rootElement && rootElement.parentNode !== container) {
651
- process.env.NODE_ENV !== 'production' ? warning(
652
- // Call internalGetID here because getID calls isValid which calls
653
- // findReactContainerForID (this function).
654
- internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') : undefined;
655
- var containerChild = container.firstChild;
656
- if (containerChild && reactRootID === internalGetID(containerChild)) {
657
- // If the container has a new child with the same ID as the old
658
- // root element, then rootElementsByReactRootID[reactRootID] is
659
- // just stale and needs to be updated. The case that deserves a
660
- // warning is when the container is empty.
661
- rootElementsByReactRootID[reactRootID] = containerChild;
662
- } else {
663
- process.env.NODE_ENV !== 'production' ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined;
664
- }
665
- }
666
- }
667
-
668
- return container;
669
- },
670
-
671
- /**
672
- * Finds an element rendered by React with the supplied ID.
673
- *
674
- * @param {string} id ID of a DOM node in the React component.
675
- * @return {DOMElement} Root DOM node of the React component.
676
- */
677
- findReactNodeByID: function (id) {
678
- var reactRoot = ReactMount.findReactContainerForID(id);
679
- return ReactMount.findComponentRoot(reactRoot, id);
680
- },
681
-
682
- /**
683
- * Traverses up the ancestors of the supplied node to find a node that is a
684
- * DOM representation of a React component rendered by this copy of React.
685
- *
686
- * @param {*} node
687
- * @return {?DOMEventTarget}
688
- * @internal
689
- */
690
- getFirstReactDOM: function (node) {
691
- return findFirstReactDOMImpl(node);
692
- },
693
-
694
- /**
695
- * Finds a node with the supplied `targetID` inside of the supplied
696
- * `ancestorNode`. Exploits the ID naming scheme to perform the search
697
- * quickly.
698
- *
699
- * @param {DOMEventTarget} ancestorNode Search from this root.
700
- * @pararm {string} targetID ID of the DOM representation of the component.
701
- * @return {DOMEventTarget} DOM node with the supplied `targetID`.
702
- * @internal
703
- */
704
- findComponentRoot: function (ancestorNode, targetID) {
705
- var firstChildren = findComponentRootReusableArray;
706
- var childIndex = 0;
707
-
708
- var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
709
-
710
- if (process.env.NODE_ENV !== 'production') {
711
- // This will throw on the next line; give an early warning
712
- 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;
713
- }
714
-
715
- firstChildren[0] = deepestAncestor.firstChild;
716
- firstChildren.length = 1;
717
-
718
- while (childIndex < firstChildren.length) {
719
- var child = firstChildren[childIndex++];
720
- var targetChild;
721
-
722
- while (child) {
723
- var childID = ReactMount.getID(child);
724
- if (childID) {
725
- // Even if we find the node we're looking for, we finish looping
726
- // through its siblings to ensure they're cached so that we don't have
727
- // to revisit this node again. Otherwise, we make n^2 calls to getID
728
- // when visiting the many children of a single node in order.
729
-
730
- if (targetID === childID) {
731
- targetChild = child;
732
- } else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) {
733
- // If we find a child whose ID is an ancestor of the given ID,
734
- // then we can be sure that we only want to search the subtree
735
- // rooted at this child, so we can throw out the rest of the
736
- // search state.
737
- firstChildren.length = childIndex = 0;
738
- firstChildren.push(child.firstChild);
739
- }
740
- } else {
741
- // If this child had no ID, then there's a chance that it was
742
- // injected automatically by the browser, as when a `<table>`
743
- // element sprouts an extra `<tbody>` child as a side effect of
744
- // `.innerHTML` parsing. Optimistically continue down this
745
- // branch, but not before examining the other siblings.
746
- firstChildren.push(child.firstChild);
747
- }
748
-
749
- child = child.nextSibling;
750
- }
751
-
752
- if (targetChild) {
753
- // Emptying firstChildren/findComponentRootReusableArray is
754
- // not necessary for correctness, but it helps the GC reclaim
755
- // any nodes that were left at the end of the search.
756
- firstChildren.length = 0;
757
-
758
- return targetChild;
759
- }
760
- }
761
-
762
- firstChildren.length = 0;
763
-
764
- !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;
765
- },
766
-
767
- _mountImageIntoNode: function (markup, container, shouldReuseMarkup, transaction) {
768
- !(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;
413
+ _mountImageIntoNode: function (markup, container, instance, shouldReuseMarkup, transaction) {
414
+ !(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) : void 0;
769
415
 
770
416
  if (shouldReuseMarkup) {
771
417
  var rootElement = getReactRootElementInContainer(container);
772
418
  if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
419
+ ReactDOMComponentTree.precacheNode(instance, rootElement);
773
420
  return;
774
421
  } else {
775
422
  var checksum = rootElement.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
@@ -801,45 +448,26 @@ var ReactMount = {
801
448
  var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
802
449
  var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
803
450
 
804
- !(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;
451
+ !(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) : void 0;
805
452
 
806
453
  if (process.env.NODE_ENV !== 'production') {
807
- 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;
454
+ 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) : void 0;
808
455
  }
809
456
  }
810
457
  }
811
458
 
812
- !(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;
459
+ !(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) : void 0;
813
460
 
814
461
  if (transaction.useCreateElement) {
815
462
  while (container.lastChild) {
816
463
  container.removeChild(container.lastChild);
817
464
  }
818
- container.appendChild(markup);
465
+ DOMLazyTree.insertTreeBefore(container, markup, null);
819
466
  } else {
820
467
  setInnerHTML(container, markup);
468
+ ReactDOMComponentTree.precacheNode(instance, container.firstChild);
821
469
  }
822
- },
823
-
824
- ownerDocumentContextKey: ownerDocumentContextKey,
825
-
826
- /**
827
- * React ID utilities.
828
- */
829
-
830
- getReactRootID: getReactRootID,
831
-
832
- getID: getID,
833
-
834
- setID: setID,
835
-
836
- getNode: getNode,
837
-
838
- getNodeFromInstance: getNodeFromInstance,
839
-
840
- isValid: isValid,
841
-
842
- purgeID: purgeID
470
+ }
843
471
  };
844
472
 
845
473
  ReactPerf.measureMethods(ReactMount, 'ReactMount', {