react 15.3.2-rc.1 → 15.4.0-rc.3

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 (209) hide show
  1. package/dist/react-with-addons.js +3863 -21388
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2639 -19486
  4. package/dist/react.min.js +2 -6
  5. package/lib/KeyEscapeUtils.js +0 -1
  6. package/lib/LinkedStateMixin.js +1 -3
  7. package/lib/PooledClass.js +3 -1
  8. package/lib/React.js +0 -1
  9. package/lib/ReactAddonsDOMDependencies.js +35 -0
  10. package/lib/ReactAddonsDOMDependenciesUMDShim.js +31 -0
  11. package/lib/ReactCSSTransitionGroup.js +60 -43
  12. package/lib/ReactCSSTransitionGroupChild.js +2 -3
  13. package/lib/ReactChildren.js +0 -1
  14. package/lib/ReactClass.js +38 -54
  15. package/lib/ReactComponent.js +0 -1
  16. package/lib/ReactComponentTreeDevtool.js +0 -1
  17. package/lib/ReactComponentTreeHook.js +84 -101
  18. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +4 -7
  19. package/lib/ReactComponentWithPureRenderMixin.js +0 -1
  20. package/lib/ReactCurrentOwner.js +1 -2
  21. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +5 -4
  22. package/lib/ReactDOMFactories.js +0 -1
  23. package/lib/ReactElement.js +6 -14
  24. package/lib/ReactElementSymbol.js +19 -0
  25. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +3 -9
  26. package/lib/ReactElementValidator.js +1 -3
  27. package/lib/ReactFragment.js +0 -1
  28. package/lib/ReactLink.js +0 -1
  29. package/lib/ReactNoopUpdateQueue.js +0 -1
  30. package/lib/ReactPropTypeLocationNames.js +1 -1
  31. package/lib/ReactPropTypeLocations.js +2 -12
  32. package/lib/ReactPropTypes.js +5 -3
  33. package/lib/ReactPropTypesSecret.js +1 -1
  34. package/lib/ReactPureComponent.js +0 -1
  35. package/lib/ReactStateSetters.js +0 -1
  36. package/lib/ReactTransitionChildMapping.js +0 -1
  37. package/lib/ReactTransitionEvents.js +1 -2
  38. package/lib/ReactTransitionGroup.js +145 -142
  39. package/lib/ReactUMDEntry.js +11 -6
  40. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +3 -6
  41. package/lib/ReactVersion.js +1 -2
  42. package/lib/ReactWithAddons.js +15 -3
  43. package/lib/ReactWithAddonsUMDEntry.js +11 -6
  44. package/lib/canDefineProperty.js +2 -1
  45. package/lib/checkReactTypeSpec.js +0 -1
  46. package/lib/deprecated.js +0 -1
  47. package/lib/flattenChildren.js +0 -1
  48. package/lib/getIteratorFn.js +0 -1
  49. package/lib/onlyChild.js +0 -1
  50. package/lib/reactProdInvariant.js +0 -1
  51. package/lib/sliceChildren.js +0 -1
  52. package/lib/traverseAllChildren.js +11 -3
  53. package/lib/update.js +6 -8
  54. package/package.json +1 -1
  55. package/lib/AutoFocusUtils.js +0 -24
  56. package/lib/BeforeInputEventPlugin.js +0 -390
  57. package/lib/CSSProperty.js +0 -148
  58. package/lib/CSSPropertyOperations.js +0 -205
  59. package/lib/CallbackQueue.js +0 -106
  60. package/lib/ChangeEventPlugin.js +0 -325
  61. package/lib/DOMChildrenOperations.js +0 -194
  62. package/lib/DOMLazyTree.js +0 -118
  63. package/lib/DOMProperty.js +0 -206
  64. package/lib/DOMPropertyOperations.js +0 -221
  65. package/lib/Danger.js +0 -48
  66. package/lib/DefaultEventPluginOrder.js +0 -27
  67. package/lib/DisabledInputUtils.js +0 -50
  68. package/lib/EnterLeaveEventPlugin.js +0 -105
  69. package/lib/EventConstants.js +0 -97
  70. package/lib/EventPluginHub.js +0 -251
  71. package/lib/EventPluginRegistry.js +0 -247
  72. package/lib/EventPluginUtils.js +0 -229
  73. package/lib/EventPropagators.js +0 -137
  74. package/lib/FallbackCompositionState.js +0 -95
  75. package/lib/HTMLDOMPropertyConfig.js +0 -212
  76. package/lib/LinkedValueUtils.js +0 -136
  77. package/lib/NativeMethodsMixin.js +0 -167
  78. package/lib/ReactBrowserEventEmitter.js +0 -330
  79. package/lib/ReactChildReconciler.js +0 -154
  80. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  81. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  82. package/lib/ReactComponentEnvironment.js +0 -45
  83. package/lib/ReactComponentTreeTestUtils.js +0 -87
  84. package/lib/ReactCompositeComponent.js +0 -904
  85. package/lib/ReactDOM.js +0 -110
  86. package/lib/ReactDOMButton.js +0 -24
  87. package/lib/ReactDOMComponent.js +0 -1006
  88. package/lib/ReactDOMComponentTree.js +0 -188
  89. package/lib/ReactDOMContainerInfo.js +0 -33
  90. package/lib/ReactDOMEmptyComponent.js +0 -60
  91. package/lib/ReactDOMFiber.js +0 -76
  92. package/lib/ReactDOMIDOperations.js +0 -34
  93. package/lib/ReactDOMInput.js +0 -269
  94. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  95. package/lib/ReactDOMOption.js +0 -123
  96. package/lib/ReactDOMSelect.js +0 -201
  97. package/lib/ReactDOMSelection.js +0 -212
  98. package/lib/ReactDOMServer.js +0 -26
  99. package/lib/ReactDOMTextComponent.js +0 -164
  100. package/lib/ReactDOMTextarea.js +0 -155
  101. package/lib/ReactDOMTreeTraversal.js +0 -136
  102. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  103. package/lib/ReactDebugTool.js +0 -301
  104. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  105. package/lib/ReactDefaultInjection.js +0 -84
  106. package/lib/ReactEmptyComponent.js +0 -30
  107. package/lib/ReactErrorUtils.js +0 -76
  108. package/lib/ReactEventEmitterMixin.js +0 -33
  109. package/lib/ReactEventListener.js +0 -157
  110. package/lib/ReactFeatureFlags.js +0 -22
  111. package/lib/ReactHostComponent.js +0 -76
  112. package/lib/ReactHostOperationHistoryHook.js +0 -37
  113. package/lib/ReactInjection.js +0 -36
  114. package/lib/ReactInputSelection.js +0 -124
  115. package/lib/ReactInstanceHandles.js +0 -302
  116. package/lib/ReactInstanceMap.js +0 -48
  117. package/lib/ReactInstrumentation.js +0 -21
  118. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  119. package/lib/ReactMarkupChecksum.js +0 -50
  120. package/lib/ReactMount.js +0 -534
  121. package/lib/ReactMultiChild.js +0 -451
  122. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  123. package/lib/ReactNative.js +0 -71
  124. package/lib/ReactNativeAttributePayload.js +0 -371
  125. package/lib/ReactNativeBaseComponent.js +0 -198
  126. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  127. package/lib/ReactNativeComponentEnvironment.js +0 -31
  128. package/lib/ReactNativeComponentTree.js +0 -68
  129. package/lib/ReactNativeContainerInfo.js +0 -21
  130. package/lib/ReactNativeDOMIDOperations.js +0 -79
  131. package/lib/ReactNativeDefaultInjection.js +0 -101
  132. package/lib/ReactNativeEventEmitter.js +0 -191
  133. package/lib/ReactNativeEventPluginOrder.js +0 -16
  134. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  135. package/lib/ReactNativeMount.js +0 -193
  136. package/lib/ReactNativePropRegistry.js +0 -52
  137. package/lib/ReactNativeReconcileTransaction.js +0 -129
  138. package/lib/ReactNativeTagHandles.js +0 -56
  139. package/lib/ReactNativeTextComponent.js +0 -71
  140. package/lib/ReactNativeTreeTraversal.js +0 -127
  141. package/lib/ReactNodeTypes.js +0 -40
  142. package/lib/ReactNoop.js +0 -173
  143. package/lib/ReactOwner.js +0 -94
  144. package/lib/ReactPerf.js +0 -494
  145. package/lib/ReactReconcileTransaction.js +0 -178
  146. package/lib/ReactReconciler.js +0 -168
  147. package/lib/ReactRef.js +0 -80
  148. package/lib/ReactServerBatchingStrategy.js +0 -22
  149. package/lib/ReactServerRendering.js +0 -90
  150. package/lib/ReactServerRenderingTransaction.js +0 -90
  151. package/lib/ReactServerUpdateQueue.js +0 -141
  152. package/lib/ReactSimpleEmptyComponent.js +0 -37
  153. package/lib/ReactTestMount.js +0 -126
  154. package/lib/ReactTestReconcileTransaction.js +0 -121
  155. package/lib/ReactTestRenderer.js +0 -144
  156. package/lib/ReactTestUtils.js +0 -518
  157. package/lib/ReactUpdateQueue.js +0 -226
  158. package/lib/ReactUpdates.js +0 -251
  159. package/lib/ResponderEventPlugin.js +0 -510
  160. package/lib/ResponderSyntheticEvent.js +0 -39
  161. package/lib/ResponderTouchHistoryStore.js +0 -184
  162. package/lib/SVGDOMPropertyConfig.js +0 -302
  163. package/lib/SelectEventPlugin.js +0 -196
  164. package/lib/SimpleEventPlugin.js +0 -635
  165. package/lib/SyntheticAnimationEvent.js +0 -39
  166. package/lib/SyntheticClipboardEvent.js +0 -38
  167. package/lib/SyntheticCompositionEvent.js +0 -36
  168. package/lib/SyntheticDragEvent.js +0 -36
  169. package/lib/SyntheticEvent.js +0 -268
  170. package/lib/SyntheticFocusEvent.js +0 -36
  171. package/lib/SyntheticInputEvent.js +0 -37
  172. package/lib/SyntheticKeyboardEvent.js +0 -84
  173. package/lib/SyntheticMouseEvent.js +0 -72
  174. package/lib/SyntheticTouchEvent.js +0 -45
  175. package/lib/SyntheticTransitionEvent.js +0 -39
  176. package/lib/SyntheticUIEvent.js +0 -59
  177. package/lib/SyntheticWheelEvent.js +0 -54
  178. package/lib/TapEventPlugin.js +0 -110
  179. package/lib/TouchHistoryMath.js +0 -99
  180. package/lib/Transaction.js +0 -233
  181. package/lib/ViewportMetrics.js +0 -27
  182. package/lib/accumulate.js +0 -46
  183. package/lib/accumulateInto.js +0 -58
  184. package/lib/adler32.js +0 -44
  185. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  186. package/lib/createReactNativeComponentClass.js +0 -42
  187. package/lib/dangerousStyleValue.js +0 -79
  188. package/lib/escapeTextContentForBrowser.js +0 -123
  189. package/lib/findDOMNode.js +0 -60
  190. package/lib/findNodeHandle.js +0 -91
  191. package/lib/forEachAccumulated.js +0 -31
  192. package/lib/getEventCharCode.js +0 -50
  193. package/lib/getEventKey.js +0 -102
  194. package/lib/getEventModifierState.js +0 -43
  195. package/lib/getEventTarget.js +0 -35
  196. package/lib/getHostComponentFromComposite.js +0 -30
  197. package/lib/getNodeForCharacterOffset.js +0 -74
  198. package/lib/getTestDocument.js +0 -21
  199. package/lib/getTextContentAccessor.js +0 -33
  200. package/lib/getVendorPrefixedEventName.js +0 -101
  201. package/lib/instantiateReactComponent.js +0 -119
  202. package/lib/isEventSupported.js +0 -60
  203. package/lib/isTextInputElement.js +0 -51
  204. package/lib/quoteAttributeValueForBrowser.js +0 -26
  205. package/lib/reactComponentExpect.js +0 -217
  206. package/lib/setInnerHTML.js +0 -98
  207. package/lib/setTextContent.js +0 -48
  208. package/lib/shouldUpdateReactComponent.js +0 -42
  209. package/lib/validateDOMNesting.js +0 -382
@@ -1,48 +0,0 @@
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 ReactInstanceMap
10
- */
11
-
12
- 'use strict';
13
-
14
- /**
15
- * `ReactInstanceMap` maintains a mapping from a public facing stateful
16
- * instance (key) and the internal representation (value). This allows public
17
- * methods to accept the user facing instance as an argument and map them back
18
- * to internal methods.
19
- */
20
-
21
- // TODO: Replace this with ES6: var ReactInstanceMap = new Map();
22
-
23
- var ReactInstanceMap = {
24
-
25
- /**
26
- * This API should be called `delete` but we'd have to make sure to always
27
- * transform these to strings for IE support. When this transform is fully
28
- * supported we can rename it.
29
- */
30
- remove: function (key) {
31
- key._reactInternalInstance = undefined;
32
- },
33
-
34
- get: function (key) {
35
- return key._reactInternalInstance;
36
- },
37
-
38
- has: function (key) {
39
- return key._reactInternalInstance !== undefined;
40
- },
41
-
42
- set: function (key, value) {
43
- key._reactInternalInstance = value;
44
- }
45
-
46
- };
47
-
48
- module.exports = ReactInstanceMap;
@@ -1,21 +0,0 @@
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 debugTool = null;
15
-
16
- if (process.env.NODE_ENV !== 'production') {
17
- var ReactDebugTool = require('./ReactDebugTool');
18
- debugTool = ReactDebugTool;
19
- }
20
-
21
- module.exports = { debugTool: debugTool };
@@ -1,36 +0,0 @@
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 ReactInvalidSetStateWarningHook
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 ReactInvalidSetStateWarningHook = {
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 = ReactInvalidSetStateWarningHook;
@@ -1,50 +0,0 @@
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 ReactMarkupChecksum
10
- */
11
-
12
- 'use strict';
13
-
14
- var adler32 = require('./adler32');
15
-
16
- var TAG_END = /\/?>/;
17
- var COMMENT_START = /^<\!\-\-/;
18
-
19
- var ReactMarkupChecksum = {
20
- CHECKSUM_ATTR_NAME: 'data-react-checksum',
21
-
22
- /**
23
- * @param {string} markup Markup string
24
- * @return {string} Markup string with checksum attribute attached
25
- */
26
- addChecksumToMarkup: function (markup) {
27
- var checksum = adler32(markup);
28
-
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
- }
35
- },
36
-
37
- /**
38
- * @param {string} markup to use
39
- * @param {DOMElement} element root React element
40
- * @returns {boolean} whether or not the markup is the same
41
- */
42
- canReuseMarkup: function (markup, element) {
43
- var existingChecksum = element.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
44
- existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
45
- var markupChecksum = adler32(markup);
46
- return markupChecksum === existingChecksum;
47
- }
48
- };
49
-
50
- module.exports = ReactMarkupChecksum;
package/lib/ReactMount.js DELETED
@@ -1,534 +0,0 @@
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 ReactMount
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant');
15
-
16
- var DOMLazyTree = require('./DOMLazyTree');
17
- var DOMProperty = require('./DOMProperty');
18
- var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
19
- var ReactCurrentOwner = require('./ReactCurrentOwner');
20
- var ReactDOMComponentTree = require('./ReactDOMComponentTree');
21
- var ReactDOMContainerInfo = require('./ReactDOMContainerInfo');
22
- var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
23
- var ReactElement = require('./ReactElement');
24
- var ReactFeatureFlags = require('./ReactFeatureFlags');
25
- var ReactInstanceMap = require('./ReactInstanceMap');
26
- var ReactInstrumentation = require('./ReactInstrumentation');
27
- var ReactMarkupChecksum = require('./ReactMarkupChecksum');
28
- var ReactReconciler = require('./ReactReconciler');
29
- var ReactUpdateQueue = require('./ReactUpdateQueue');
30
- var ReactUpdates = require('./ReactUpdates');
31
-
32
- var emptyObject = require('fbjs/lib/emptyObject');
33
- var instantiateReactComponent = require('./instantiateReactComponent');
34
- var invariant = require('fbjs/lib/invariant');
35
- var setInnerHTML = require('./setInnerHTML');
36
- var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
37
- var warning = require('fbjs/lib/warning');
38
-
39
- var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
40
- var ROOT_ATTR_NAME = DOMProperty.ROOT_ATTRIBUTE_NAME;
41
-
42
- var ELEMENT_NODE_TYPE = 1;
43
- var DOC_NODE_TYPE = 9;
44
- var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
45
-
46
- var instancesByReactRootID = {};
47
-
48
- /**
49
- * Finds the index of the first character
50
- * that's not common between the two given strings.
51
- *
52
- * @return {number} the index of the character where the strings diverge
53
- */
54
- function firstDifferenceIndex(string1, string2) {
55
- var minLen = Math.min(string1.length, string2.length);
56
- for (var i = 0; i < minLen; i++) {
57
- if (string1.charAt(i) !== string2.charAt(i)) {
58
- return i;
59
- }
60
- }
61
- return string1.length === string2.length ? -1 : minLen;
62
- }
63
-
64
- /**
65
- * @param {DOMElement|DOMDocument} container DOM element that may contain
66
- * a React component
67
- * @return {?*} DOM element that may have the reactRoot ID, or null.
68
- */
69
- function getReactRootElementInContainer(container) {
70
- if (!container) {
71
- return null;
72
- }
73
-
74
- if (container.nodeType === DOC_NODE_TYPE) {
75
- return container.documentElement;
76
- } else {
77
- return container.firstChild;
78
- }
79
- }
80
-
81
- function internalGetID(node) {
82
- // If node is something like a window, document, or text node, none of
83
- // which support attributes or a .getAttribute method, gracefully return
84
- // the empty string, as if the attribute were missing.
85
- return node.getAttribute && node.getAttribute(ATTR_NAME) || '';
86
- }
87
-
88
- /**
89
- * Mounts this component and inserts it into the DOM.
90
- *
91
- * @param {ReactComponent} componentInstance The instance to mount.
92
- * @param {DOMElement} container DOM element to mount into.
93
- * @param {ReactReconcileTransaction} transaction
94
- * @param {boolean} shouldReuseMarkup If true, do not insert markup
95
- */
96
- function mountComponentIntoNode(wrapperInstance, container, transaction, shouldReuseMarkup, context) {
97
- var markerName;
98
- if (ReactFeatureFlags.logTopLevelRenders) {
99
- var wrappedElement = wrapperInstance._currentElement.props;
100
- var type = wrappedElement.type;
101
- markerName = 'React mount: ' + (typeof type === 'string' ? type : type.displayName || type.name);
102
- console.time(markerName);
103
- }
104
-
105
- var markup = ReactReconciler.mountComponent(wrapperInstance, transaction, null, ReactDOMContainerInfo(wrapperInstance, container), context, 0 /* parentDebugID */
106
- );
107
-
108
- if (markerName) {
109
- console.timeEnd(markerName);
110
- }
111
-
112
- wrapperInstance._renderedComponent._topLevelWrapper = wrapperInstance;
113
- ReactMount._mountImageIntoNode(markup, container, wrapperInstance, shouldReuseMarkup, transaction);
114
- }
115
-
116
- /**
117
- * Batched mount.
118
- *
119
- * @param {ReactComponent} componentInstance The instance to mount.
120
- * @param {DOMElement} container DOM element to mount into.
121
- * @param {boolean} shouldReuseMarkup If true, do not insert markup
122
- */
123
- function batchedMountComponentIntoNode(componentInstance, container, shouldReuseMarkup, context) {
124
- var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
125
- /* useCreateElement */
126
- !shouldReuseMarkup && ReactDOMFeatureFlags.useCreateElement);
127
- transaction.perform(mountComponentIntoNode, null, componentInstance, container, transaction, shouldReuseMarkup, context);
128
- ReactUpdates.ReactReconcileTransaction.release(transaction);
129
- }
130
-
131
- /**
132
- * Unmounts a component and removes it from the DOM.
133
- *
134
- * @param {ReactComponent} instance React component instance.
135
- * @param {DOMElement} container DOM element to unmount from.
136
- * @final
137
- * @internal
138
- * @see {ReactMount.unmountComponentAtNode}
139
- */
140
- function unmountComponentFromNode(instance, container, safely) {
141
- if (process.env.NODE_ENV !== 'production') {
142
- ReactInstrumentation.debugTool.onBeginFlush();
143
- }
144
- ReactReconciler.unmountComponent(instance, safely);
145
- if (process.env.NODE_ENV !== 'production') {
146
- ReactInstrumentation.debugTool.onEndFlush();
147
- }
148
-
149
- if (container.nodeType === DOC_NODE_TYPE) {
150
- container = container.documentElement;
151
- }
152
-
153
- // http://jsperf.com/emptying-a-node
154
- while (container.lastChild) {
155
- container.removeChild(container.lastChild);
156
- }
157
- }
158
-
159
- /**
160
- * True if the supplied DOM node has a direct React-rendered child that is
161
- * not a React root element. Useful for warning in `render`,
162
- * `unmountComponentAtNode`, etc.
163
- *
164
- * @param {?DOMElement} node The candidate DOM node.
165
- * @return {boolean} True if the DOM element contains a direct child that was
166
- * rendered by React but is not a root element.
167
- * @internal
168
- */
169
- function hasNonRootReactChild(container) {
170
- var rootEl = getReactRootElementInContainer(container);
171
- if (rootEl) {
172
- var inst = ReactDOMComponentTree.getInstanceFromNode(rootEl);
173
- return !!(inst && inst._hostParent);
174
- }
175
- }
176
-
177
- /**
178
- * True if the supplied DOM node is a React DOM element and
179
- * it has been rendered by another copy of React.
180
- *
181
- * @param {?DOMElement} node The candidate DOM node.
182
- * @return {boolean} True if the DOM has been rendered by another copy of React
183
- * @internal
184
- */
185
- function nodeIsRenderedByOtherInstance(container) {
186
- var rootEl = getReactRootElementInContainer(container);
187
- return !!(rootEl && isReactNode(rootEl) && !ReactDOMComponentTree.getInstanceFromNode(rootEl));
188
- }
189
-
190
- /**
191
- * True if the supplied DOM node is a valid node element.
192
- *
193
- * @param {?DOMElement} node The candidate DOM node.
194
- * @return {boolean} True if the DOM is a valid DOM node.
195
- * @internal
196
- */
197
- function isValidContainer(node) {
198
- return !!(node && (node.nodeType === ELEMENT_NODE_TYPE || node.nodeType === DOC_NODE_TYPE || node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE));
199
- }
200
-
201
- /**
202
- * True if the supplied DOM node is a valid React node element.
203
- *
204
- * @param {?DOMElement} node The candidate DOM node.
205
- * @return {boolean} True if the DOM is a valid React DOM node.
206
- * @internal
207
- */
208
- function isReactNode(node) {
209
- return isValidContainer(node) && (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME));
210
- }
211
-
212
- function getHostRootInstanceInContainer(container) {
213
- var rootEl = getReactRootElementInContainer(container);
214
- var prevHostInstance = rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl);
215
- return prevHostInstance && !prevHostInstance._hostParent ? prevHostInstance : null;
216
- }
217
-
218
- function getTopLevelWrapperInContainer(container) {
219
- var root = getHostRootInstanceInContainer(container);
220
- return root ? root._hostContainerInfo._topLevelWrapper : null;
221
- }
222
-
223
- /**
224
- * Temporary (?) hack so that we can store all top-level pending updates on
225
- * composites instead of having to worry about different types of components
226
- * here.
227
- */
228
- var topLevelRootCounter = 1;
229
- var TopLevelWrapper = function () {
230
- this.rootID = topLevelRootCounter++;
231
- };
232
- TopLevelWrapper.prototype.isReactComponent = {};
233
- if (process.env.NODE_ENV !== 'production') {
234
- TopLevelWrapper.displayName = 'TopLevelWrapper';
235
- }
236
- TopLevelWrapper.prototype.render = function () {
237
- // this.props is actually a ReactElement
238
- return this.props;
239
- };
240
-
241
- /**
242
- * Mounting is the process of initializing a React component by creating its
243
- * representative DOM elements and inserting them into a supplied `container`.
244
- * Any prior content inside `container` is destroyed in the process.
245
- *
246
- * ReactMount.render(
247
- * component,
248
- * document.getElementById('container')
249
- * );
250
- *
251
- * <div id="container"> <-- Supplied `container`.
252
- * <div data-reactid=".3"> <-- Rendered reactRoot of React
253
- * // ... component.
254
- * </div>
255
- * </div>
256
- *
257
- * Inside of `container`, the first element rendered is the "reactRoot".
258
- */
259
- var ReactMount = {
260
-
261
- TopLevelWrapper: TopLevelWrapper,
262
-
263
- /**
264
- * Used by devtools. The keys are not important.
265
- */
266
- _instancesByReactRootID: instancesByReactRootID,
267
-
268
- /**
269
- * This is a hook provided to support rendering React components while
270
- * ensuring that the apparent scroll position of its `container` does not
271
- * change.
272
- *
273
- * @param {DOMElement} container The `container` being rendered into.
274
- * @param {function} renderCallback This must be called once to do the render.
275
- */
276
- scrollMonitor: function (container, renderCallback) {
277
- renderCallback();
278
- },
279
-
280
- /**
281
- * Take a component that's already mounted into the DOM and replace its props
282
- * @param {ReactComponent} prevComponent component instance already in the DOM
283
- * @param {ReactElement} nextElement component instance to render
284
- * @param {DOMElement} container container to render into
285
- * @param {?function} callback function triggered on completion
286
- */
287
- _updateRootComponent: function (prevComponent, nextElement, nextContext, container, callback) {
288
- ReactMount.scrollMonitor(container, function () {
289
- ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement, nextContext);
290
- if (callback) {
291
- ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
292
- }
293
- });
294
-
295
- return prevComponent;
296
- },
297
-
298
- /**
299
- * Render a new component into the DOM. Hooked by hooks!
300
- *
301
- * @param {ReactElement} nextElement element to render
302
- * @param {DOMElement} container container to render into
303
- * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
304
- * @return {ReactComponent} nextComponent
305
- */
306
- _renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context) {
307
- // Various parts of our code (such as ReactCompositeComponent's
308
- // _renderValidatedComponent) assume that calls to render aren't nested;
309
- // verify that that's the case.
310
- 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;
311
-
312
- !isValidContainer(container) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : _prodInvariant('37') : void 0;
313
-
314
- ReactBrowserEventEmitter.ensureScrollValueMonitoring();
315
- var componentInstance = instantiateReactComponent(nextElement, false);
316
-
317
- // The initial render is synchronous but any updates that happen during
318
- // rendering, in componentWillMount or componentDidMount, will be batched
319
- // according to the current batching strategy.
320
-
321
- ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, container, shouldReuseMarkup, context);
322
-
323
- var wrapperID = componentInstance._instance.rootID;
324
- instancesByReactRootID[wrapperID] = componentInstance;
325
-
326
- return componentInstance;
327
- },
328
-
329
- /**
330
- * Renders a React component into the DOM in the supplied `container`.
331
- *
332
- * If the React component was previously rendered into `container`, this will
333
- * perform an update on it and only mutate the DOM as necessary to reflect the
334
- * latest React component.
335
- *
336
- * @param {ReactComponent} parentComponent The conceptual parent of this render tree.
337
- * @param {ReactElement} nextElement Component element to render.
338
- * @param {DOMElement} container DOM element to render into.
339
- * @param {?function} callback function triggered on completion
340
- * @return {ReactComponent} Component instance rendered in `container`.
341
- */
342
- renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
343
- !(parentComponent != null && ReactInstanceMap.has(parentComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : _prodInvariant('38') : void 0;
344
- return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
345
- },
346
-
347
- _renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
348
- ReactUpdateQueue.validateCallback(callback, 'ReactDOM.render');
349
- !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 />.' :
350
- // Check if it quacks like an element
351
- nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : _prodInvariant('39', 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 />.' : nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : void 0;
352
-
353
- 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;
354
-
355
- var nextWrappedElement = ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
356
-
357
- var nextContext;
358
- if (parentComponent) {
359
- var parentInst = ReactInstanceMap.get(parentComponent);
360
- nextContext = parentInst._processChildContext(parentInst._context);
361
- } else {
362
- nextContext = emptyObject;
363
- }
364
-
365
- var prevComponent = getTopLevelWrapperInContainer(container);
366
-
367
- if (prevComponent) {
368
- var prevWrappedElement = prevComponent._currentElement;
369
- var prevElement = prevWrappedElement.props;
370
- if (shouldUpdateReactComponent(prevElement, nextElement)) {
371
- var publicInst = prevComponent._renderedComponent.getPublicInstance();
372
- var updatedCallback = callback && function () {
373
- callback.call(publicInst);
374
- };
375
- ReactMount._updateRootComponent(prevComponent, nextWrappedElement, nextContext, container, updatedCallback);
376
- return publicInst;
377
- } else {
378
- ReactMount.unmountComponentAtNode(container);
379
- }
380
- }
381
-
382
- var reactRootElement = getReactRootElementInContainer(container);
383
- var containerHasReactMarkup = reactRootElement && !!internalGetID(reactRootElement);
384
- var containerHasNonRootReactChild = hasNonRootReactChild(container);
385
-
386
- if (process.env.NODE_ENV !== 'production') {
387
- 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;
388
-
389
- if (!containerHasReactMarkup || reactRootElement.nextSibling) {
390
- var rootElementSibling = reactRootElement;
391
- while (rootElementSibling) {
392
- if (internalGetID(rootElementSibling)) {
393
- 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;
394
- break;
395
- }
396
- rootElementSibling = rootElementSibling.nextSibling;
397
- }
398
- }
399
- }
400
-
401
- var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild;
402
- var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, nextContext)._renderedComponent.getPublicInstance();
403
- if (callback) {
404
- callback.call(component);
405
- }
406
- return component;
407
- },
408
-
409
- /**
410
- * Renders a React component into the DOM in the supplied `container`.
411
- * See https://facebook.github.io/react/docs/top-level-api.html#reactdom.render
412
- *
413
- * If the React component was previously rendered into `container`, this will
414
- * perform an update on it and only mutate the DOM as necessary to reflect the
415
- * latest React component.
416
- *
417
- * @param {ReactElement} nextElement Component element to render.
418
- * @param {DOMElement} container DOM element to render into.
419
- * @param {?function} callback function triggered on completion
420
- * @return {ReactComponent} Component instance rendered in `container`.
421
- */
422
- render: function (nextElement, container, callback) {
423
- return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
424
- },
425
-
426
- /**
427
- * Unmounts and destroys the React component rendered in the `container`.
428
- * See https://facebook.github.io/react/docs/top-level-api.html#reactdom.unmountcomponentatnode
429
- *
430
- * @param {DOMElement} container DOM element containing a React component.
431
- * @return {boolean} True if a component was found in and unmounted from
432
- * `container`
433
- */
434
- unmountComponentAtNode: function (container) {
435
- // Various parts of our code (such as ReactCompositeComponent's
436
- // _renderValidatedComponent) assume that calls to render aren't nested;
437
- // verify that that's the case. (Strictly speaking, unmounting won't cause a
438
- // render but we still don't expect to be in a render call here.)
439
- 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;
440
-
441
- !isValidContainer(container) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : _prodInvariant('40') : void 0;
442
-
443
- if (process.env.NODE_ENV !== 'production') {
444
- process.env.NODE_ENV !== 'production' ? warning(!nodeIsRenderedByOtherInstance(container), 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by another copy of React.') : void 0;
445
- }
446
-
447
- var prevComponent = getTopLevelWrapperInContainer(container);
448
- if (!prevComponent) {
449
- // Check if the node being unmounted was rendered by React, but isn't a
450
- // root node.
451
- var containerHasNonRootReactChild = hasNonRootReactChild(container);
452
-
453
- // Check if the container itself is a React root node.
454
- var isContainerReactRoot = container.nodeType === 1 && container.hasAttribute(ROOT_ATTR_NAME);
455
-
456
- if (process.env.NODE_ENV !== 'production') {
457
- 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;
458
- }
459
-
460
- return false;
461
- }
462
- delete instancesByReactRootID[prevComponent._instance.rootID];
463
- ReactUpdates.batchedUpdates(unmountComponentFromNode, prevComponent, container, false);
464
- return true;
465
- },
466
-
467
- _mountImageIntoNode: function (markup, container, instance, shouldReuseMarkup, transaction) {
468
- !isValidContainer(container) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : _prodInvariant('41') : void 0;
469
-
470
- if (shouldReuseMarkup) {
471
- var rootElement = getReactRootElementInContainer(container);
472
- if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
473
- ReactDOMComponentTree.precacheNode(instance, rootElement);
474
- return;
475
- } else {
476
- var checksum = rootElement.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
477
- rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
478
-
479
- var rootMarkup = rootElement.outerHTML;
480
- rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum);
481
-
482
- var normalizedMarkup = markup;
483
- if (process.env.NODE_ENV !== 'production') {
484
- // because rootMarkup is retrieved from the DOM, various normalizations
485
- // will have occurred which will not be present in `markup`. Here,
486
- // insert markup into a <div> or <iframe> depending on the container
487
- // type to perform the same normalizations before comparing.
488
- var normalizer;
489
- if (container.nodeType === ELEMENT_NODE_TYPE) {
490
- normalizer = document.createElement('div');
491
- normalizer.innerHTML = markup;
492
- normalizedMarkup = normalizer.innerHTML;
493
- } else {
494
- normalizer = document.createElement('iframe');
495
- document.body.appendChild(normalizer);
496
- normalizer.contentDocument.write(markup);
497
- normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
498
- document.body.removeChild(normalizer);
499
- }
500
- }
501
-
502
- var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
503
- var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
504
-
505
- !(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) : _prodInvariant('42', difference) : void 0;
506
-
507
- if (process.env.NODE_ENV !== 'production') {
508
- 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;
509
- }
510
- }
511
- }
512
-
513
- !(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.') : _prodInvariant('43') : void 0;
514
-
515
- if (transaction.useCreateElement) {
516
- while (container.lastChild) {
517
- container.removeChild(container.lastChild);
518
- }
519
- DOMLazyTree.insertTreeBefore(container, markup, null);
520
- } else {
521
- setInnerHTML(container, markup);
522
- ReactDOMComponentTree.precacheNode(instance, container.firstChild);
523
- }
524
-
525
- if (process.env.NODE_ENV !== 'production') {
526
- var hostNode = ReactDOMComponentTree.getInstanceFromNode(container.firstChild);
527
- if (hostNode._debugID !== 0) {
528
- ReactInstrumentation.debugTool.onHostOperation(hostNode._debugID, 'mount', markup.toString());
529
- }
530
- }
531
- }
532
- };
533
-
534
- module.exports = ReactMount;