react-test-renderer 15.5.0 → 15.5.4

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 (168) hide show
  1. package/lib/ReactShallowRenderer.js +6 -0
  2. package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
  3. package/lib/shallow/AutoFocusUtils.js +23 -0
  4. package/lib/shallow/BeforeInputEventPlugin.js +384 -0
  5. package/lib/shallow/CSSProperty.js +147 -0
  6. package/lib/shallow/CSSPropertyOperations.js +208 -0
  7. package/lib/shallow/CallbackQueue.js +118 -0
  8. package/lib/shallow/ChangeEventPlugin.js +345 -0
  9. package/lib/shallow/DOMChildrenOperations.js +224 -0
  10. package/lib/shallow/DOMLazyTree.js +117 -0
  11. package/lib/shallow/DOMNamespaces.js +19 -0
  12. package/lib/shallow/DOMProperty.js +209 -0
  13. package/lib/shallow/DOMPropertyOperations.js +236 -0
  14. package/lib/shallow/Danger.js +47 -0
  15. package/lib/shallow/DefaultEventPluginOrder.js +25 -0
  16. package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
  17. package/lib/shallow/EventConstants.js +91 -0
  18. package/lib/shallow/EventPluginHub.js +277 -0
  19. package/lib/shallow/EventPluginRegistry.js +254 -0
  20. package/lib/shallow/EventPluginUtils.js +225 -0
  21. package/lib/shallow/EventPropagators.js +133 -0
  22. package/lib/shallow/FallbackCompositionState.js +94 -0
  23. package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
  24. package/lib/shallow/KeyEscapeUtils.js +58 -0
  25. package/lib/shallow/LinkedValueUtils.js +137 -0
  26. package/lib/shallow/PluginModuleType.js +12 -0
  27. package/lib/shallow/PooledClass.js +111 -0
  28. package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
  29. package/lib/shallow/ReactChildFiber.js +243 -0
  30. package/lib/shallow/ReactChildReconciler.js +153 -0
  31. package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
  32. package/lib/shallow/ReactComponentEnvironment.js +45 -0
  33. package/lib/shallow/ReactCompositeComponent.js +901 -0
  34. package/lib/shallow/ReactCoroutine.js +80 -0
  35. package/lib/shallow/ReactDOM.js +110 -0
  36. package/lib/shallow/ReactDOMComponent.js +1000 -0
  37. package/lib/shallow/ReactDOMComponentFlags.js +17 -0
  38. package/lib/shallow/ReactDOMComponentTree.js +194 -0
  39. package/lib/shallow/ReactDOMContainerInfo.js +32 -0
  40. package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
  41. package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
  42. package/lib/shallow/ReactDOMFiber.js +97 -0
  43. package/lib/shallow/ReactDOMIDOperations.js +33 -0
  44. package/lib/shallow/ReactDOMInput.js +284 -0
  45. package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
  46. package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
  47. package/lib/shallow/ReactDOMOption.js +122 -0
  48. package/lib/shallow/ReactDOMSelect.js +199 -0
  49. package/lib/shallow/ReactDOMSelection.js +211 -0
  50. package/lib/shallow/ReactDOMServer.js +25 -0
  51. package/lib/shallow/ReactDOMTextComponent.js +163 -0
  52. package/lib/shallow/ReactDOMTextarea.js +159 -0
  53. package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
  54. package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
  55. package/lib/shallow/ReactDebugTool.js +358 -0
  56. package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
  57. package/lib/shallow/ReactDefaultInjection.js +85 -0
  58. package/lib/shallow/ReactElementSymbol.js +19 -0
  59. package/lib/shallow/ReactEmptyComponent.js +29 -0
  60. package/lib/shallow/ReactErrorUtils.js +75 -0
  61. package/lib/shallow/ReactEventEmitterMixin.js +32 -0
  62. package/lib/shallow/ReactEventListener.js +154 -0
  63. package/lib/shallow/ReactFeatureFlags.js +21 -0
  64. package/lib/shallow/ReactFiber.js +190 -0
  65. package/lib/shallow/ReactFiberBeginWork.js +380 -0
  66. package/lib/shallow/ReactFiberCommitWork.js +78 -0
  67. package/lib/shallow/ReactFiberCompleteWork.js +208 -0
  68. package/lib/shallow/ReactFiberReconciler.js +64 -0
  69. package/lib/shallow/ReactFiberRoot.js +29 -0
  70. package/lib/shallow/ReactFiberScheduler.js +331 -0
  71. package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
  72. package/lib/shallow/ReactHostComponent.js +67 -0
  73. package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
  74. package/lib/shallow/ReactInjection.js +33 -0
  75. package/lib/shallow/ReactInputSelection.js +123 -0
  76. package/lib/shallow/ReactInstanceMap.js +47 -0
  77. package/lib/shallow/ReactInstanceType.js +12 -0
  78. package/lib/shallow/ReactInstrumentation.js +23 -0
  79. package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
  80. package/lib/shallow/ReactMarkupChecksum.js +49 -0
  81. package/lib/shallow/ReactMount.js +537 -0
  82. package/lib/shallow/ReactMultiChild.js +449 -0
  83. package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
  84. package/lib/shallow/ReactNodeTypes.js +39 -0
  85. package/lib/shallow/ReactOwner.js +93 -0
  86. package/lib/shallow/ReactPerf.js +500 -0
  87. package/lib/shallow/ReactPriorityLevel.js +20 -0
  88. package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
  89. package/lib/shallow/ReactPropTypeLocations.js +12 -0
  90. package/lib/shallow/ReactPropTypesSecret.js +16 -0
  91. package/lib/shallow/ReactReconcileTransaction.js +177 -0
  92. package/lib/shallow/ReactReconciler.js +167 -0
  93. package/lib/shallow/ReactRef.js +88 -0
  94. package/lib/shallow/ReactReifiedYield.js +30 -0
  95. package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
  96. package/lib/shallow/ReactServerRendering.js +89 -0
  97. package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
  98. package/lib/shallow/ReactServerUpdateQueue.js +138 -0
  99. package/lib/shallow/ReactShallowRenderer.js +150 -0
  100. package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
  101. package/lib/shallow/ReactSyntheticEventType.js +14 -0
  102. package/lib/shallow/ReactTestEmptyComponent.js +36 -0
  103. package/lib/shallow/ReactTestMount.js +131 -0
  104. package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
  105. package/lib/shallow/ReactTestRenderer.js +139 -0
  106. package/lib/shallow/ReactTestTextComponent.js +40 -0
  107. package/lib/shallow/ReactTypeOfWork.js +23 -0
  108. package/lib/shallow/ReactTypes.js +12 -0
  109. package/lib/shallow/ReactUpdateQueue.js +235 -0
  110. package/lib/shallow/ReactUpdates.js +250 -0
  111. package/lib/shallow/ReactVersion.js +13 -0
  112. package/lib/shallow/ResponderEventPlugin.js +507 -0
  113. package/lib/shallow/ResponderSyntheticEvent.js +38 -0
  114. package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
  115. package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
  116. package/lib/shallow/SelectEventPlugin.js +190 -0
  117. package/lib/shallow/SimpleEventPlugin.js +227 -0
  118. package/lib/shallow/SyntheticAnimationEvent.js +38 -0
  119. package/lib/shallow/SyntheticClipboardEvent.js +37 -0
  120. package/lib/shallow/SyntheticCompositionEvent.js +35 -0
  121. package/lib/shallow/SyntheticDragEvent.js +35 -0
  122. package/lib/shallow/SyntheticEvent.js +267 -0
  123. package/lib/shallow/SyntheticFocusEvent.js +35 -0
  124. package/lib/shallow/SyntheticInputEvent.js +36 -0
  125. package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
  126. package/lib/shallow/SyntheticMouseEvent.js +71 -0
  127. package/lib/shallow/SyntheticTouchEvent.js +44 -0
  128. package/lib/shallow/SyntheticTransitionEvent.js +38 -0
  129. package/lib/shallow/SyntheticUIEvent.js +58 -0
  130. package/lib/shallow/SyntheticWheelEvent.js +53 -0
  131. package/lib/shallow/TapEventPlugin.js +115 -0
  132. package/lib/shallow/TouchHistoryMath.js +98 -0
  133. package/lib/shallow/Transaction.js +224 -0
  134. package/lib/shallow/ViewportMetrics.js +26 -0
  135. package/lib/shallow/accumulate.js +45 -0
  136. package/lib/shallow/accumulateInto.js +57 -0
  137. package/lib/shallow/adler32.js +43 -0
  138. package/lib/shallow/canDefineProperty.js +25 -0
  139. package/lib/shallow/checkReactTypeSpec.js +86 -0
  140. package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
  141. package/lib/shallow/dangerousStyleValue.js +78 -0
  142. package/lib/shallow/deprecated.js +56 -0
  143. package/lib/shallow/escapeTextContentForBrowser.js +122 -0
  144. package/lib/shallow/findDOMNode.js +59 -0
  145. package/lib/shallow/flattenChildren.js +75 -0
  146. package/lib/shallow/forEachAccumulated.js +30 -0
  147. package/lib/shallow/getEventCharCode.js +49 -0
  148. package/lib/shallow/getEventKey.js +101 -0
  149. package/lib/shallow/getEventModifierState.js +42 -0
  150. package/lib/shallow/getEventTarget.js +34 -0
  151. package/lib/shallow/getHostComponentFromComposite.js +29 -0
  152. package/lib/shallow/getIteratorFn.js +40 -0
  153. package/lib/shallow/getNodeForCharacterOffset.js +73 -0
  154. package/lib/shallow/getTextContentAccessor.js +32 -0
  155. package/lib/shallow/getVendorPrefixedEventName.js +100 -0
  156. package/lib/shallow/instantiateReactComponent.js +128 -0
  157. package/lib/shallow/isEventSupported.js +59 -0
  158. package/lib/shallow/isTextInputElement.js +50 -0
  159. package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
  160. package/lib/shallow/reactProdInvariant.js +38 -0
  161. package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
  162. package/lib/shallow/setInnerHTML.js +97 -0
  163. package/lib/shallow/setTextContent.js +51 -0
  164. package/lib/shallow/shouldUpdateReactComponent.js +41 -0
  165. package/lib/shallow/traverseAllChildren.js +175 -0
  166. package/lib/shallow/validateDOMNesting.js +376 -0
  167. package/package.json +1 -1
  168. package/shallow.js +1 -1
@@ -0,0 +1,177 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _assign = require('object-assign');
14
+
15
+ var CallbackQueue = require('./CallbackQueue');
16
+ var PooledClass = require('./PooledClass');
17
+ var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
18
+ var ReactInputSelection = require('./ReactInputSelection');
19
+ var ReactInstrumentation = require('./ReactInstrumentation');
20
+ var Transaction = require('./Transaction');
21
+ var ReactUpdateQueue = require('./ReactUpdateQueue');
22
+
23
+ /**
24
+ * Ensures that, when possible, the selection range (currently selected text
25
+ * input) is not disturbed by performing the transaction.
26
+ */
27
+ var SELECTION_RESTORATION = {
28
+ /**
29
+ * @return {Selection} Selection information.
30
+ */
31
+ initialize: ReactInputSelection.getSelectionInformation,
32
+ /**
33
+ * @param {Selection} sel Selection information returned from `initialize`.
34
+ */
35
+ close: ReactInputSelection.restoreSelection
36
+ };
37
+
38
+ /**
39
+ * Suppresses events (blur/focus) that could be inadvertently dispatched due to
40
+ * high level DOM manipulations (like temporarily removing a text input from the
41
+ * DOM).
42
+ */
43
+ var EVENT_SUPPRESSION = {
44
+ /**
45
+ * @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
46
+ * the reconciliation.
47
+ */
48
+ initialize: function () {
49
+ var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
50
+ ReactBrowserEventEmitter.setEnabled(false);
51
+ return currentlyEnabled;
52
+ },
53
+
54
+ /**
55
+ * @param {boolean} previouslyEnabled Enabled status of
56
+ * `ReactBrowserEventEmitter` before the reconciliation occurred. `close`
57
+ * restores the previous value.
58
+ */
59
+ close: function (previouslyEnabled) {
60
+ ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
61
+ }
62
+ };
63
+
64
+ /**
65
+ * Provides a queue for collecting `componentDidMount` and
66
+ * `componentDidUpdate` callbacks during the transaction.
67
+ */
68
+ var ON_DOM_READY_QUEUEING = {
69
+ /**
70
+ * Initializes the internal `onDOMReady` queue.
71
+ */
72
+ initialize: function () {
73
+ this.reactMountReady.reset();
74
+ },
75
+
76
+ /**
77
+ * After DOM is flushed, invoke all registered `onDOMReady` callbacks.
78
+ */
79
+ close: function () {
80
+ this.reactMountReady.notifyAll();
81
+ }
82
+ };
83
+
84
+ /**
85
+ * Executed within the scope of the `Transaction` instance. Consider these as
86
+ * being member methods, but with an implied ordering while being isolated from
87
+ * each other.
88
+ */
89
+ var TRANSACTION_WRAPPERS = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_READY_QUEUEING];
90
+
91
+ if (process.env.NODE_ENV !== 'production') {
92
+ TRANSACTION_WRAPPERS.push({
93
+ initialize: ReactInstrumentation.debugTool.onBeginFlush,
94
+ close: ReactInstrumentation.debugTool.onEndFlush
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Currently:
100
+ * - The order that these are listed in the transaction is critical:
101
+ * - Suppresses events.
102
+ * - Restores selection range.
103
+ *
104
+ * Future:
105
+ * - Restore document/overflow scroll positions that were unintentionally
106
+ * modified via DOM insertions above the top viewport boundary.
107
+ * - Implement/integrate with customized constraint based layout system and keep
108
+ * track of which dimensions must be remeasured.
109
+ *
110
+ * @class ReactReconcileTransaction
111
+ */
112
+ function ReactReconcileTransaction(useCreateElement) {
113
+ this.reinitializeTransaction();
114
+ // Only server-side rendering really needs this option (see
115
+ // `ReactServerRendering`), but server-side uses
116
+ // `ReactServerRenderingTransaction` instead. This option is here so that it's
117
+ // accessible and defaults to false when `ReactDOMComponent` and
118
+ // `ReactDOMTextComponent` checks it in `mountComponent`.`
119
+ this.renderToStaticMarkup = false;
120
+ this.reactMountReady = CallbackQueue.getPooled(null);
121
+ this.useCreateElement = useCreateElement;
122
+ }
123
+
124
+ var Mixin = {
125
+ /**
126
+ * @see Transaction
127
+ * @abstract
128
+ * @final
129
+ * @return {array<object>} List of operation wrap procedures.
130
+ * TODO: convert to array<TransactionWrapper>
131
+ */
132
+ getTransactionWrappers: function () {
133
+ return TRANSACTION_WRAPPERS;
134
+ },
135
+
136
+ /**
137
+ * @return {object} The queue to collect `onDOMReady` callbacks with.
138
+ */
139
+ getReactMountReady: function () {
140
+ return this.reactMountReady;
141
+ },
142
+
143
+ /**
144
+ * @return {object} The queue to collect React async events.
145
+ */
146
+ getUpdateQueue: function () {
147
+ return ReactUpdateQueue;
148
+ },
149
+
150
+ /**
151
+ * Save current transaction state -- if the return value from this method is
152
+ * passed to `rollback`, the transaction will be reset to that state.
153
+ */
154
+ checkpoint: function () {
155
+ // reactMountReady is the our only stateful wrapper
156
+ return this.reactMountReady.checkpoint();
157
+ },
158
+
159
+ rollback: function (checkpoint) {
160
+ this.reactMountReady.rollback(checkpoint);
161
+ },
162
+
163
+ /**
164
+ * `PooledClass` looks for this, and will invoke this before allowing this
165
+ * instance to be reused.
166
+ */
167
+ destructor: function () {
168
+ CallbackQueue.release(this.reactMountReady);
169
+ this.reactMountReady = null;
170
+ }
171
+ };
172
+
173
+ _assign(ReactReconcileTransaction.prototype, Transaction, Mixin);
174
+
175
+ PooledClass.addPoolingTo(ReactReconcileTransaction);
176
+
177
+ module.exports = ReactReconcileTransaction;
@@ -0,0 +1,167 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var ReactRef = require('./ReactRef');
14
+ var ReactInstrumentation = require('./ReactInstrumentation');
15
+
16
+ var warning = require('fbjs/lib/warning');
17
+
18
+ /**
19
+ * Helper to call ReactRef.attachRefs with this composite component, split out
20
+ * to avoid allocations in the transaction mount-ready queue.
21
+ */
22
+ function attachRefs() {
23
+ ReactRef.attachRefs(this, this._currentElement);
24
+ }
25
+
26
+ var ReactReconciler = {
27
+
28
+ /**
29
+ * Initializes the component, renders markup, and registers event listeners.
30
+ *
31
+ * @param {ReactComponent} internalInstance
32
+ * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
33
+ * @param {?object} the containing host component instance
34
+ * @param {?object} info about the host container
35
+ * @return {?string} Rendered markup to be inserted into the DOM.
36
+ * @final
37
+ * @internal
38
+ */
39
+ mountComponent: function (internalInstance, transaction, hostParent, hostContainerInfo, context, parentDebugID // 0 in production and for roots
40
+ ) {
41
+ if (process.env.NODE_ENV !== 'production') {
42
+ if (internalInstance._debugID !== 0) {
43
+ ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
44
+ }
45
+ }
46
+ var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
47
+ if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
48
+ transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
49
+ }
50
+ if (process.env.NODE_ENV !== 'production') {
51
+ if (internalInstance._debugID !== 0) {
52
+ ReactInstrumentation.debugTool.onMountComponent(internalInstance._debugID);
53
+ }
54
+ }
55
+ return markup;
56
+ },
57
+
58
+ /**
59
+ * Returns a value that can be passed to
60
+ * ReactComponentEnvironment.replaceNodeWithMarkup.
61
+ */
62
+ getHostNode: function (internalInstance) {
63
+ return internalInstance.getHostNode();
64
+ },
65
+
66
+ /**
67
+ * Releases any resources allocated by `mountComponent`.
68
+ *
69
+ * @final
70
+ * @internal
71
+ */
72
+ unmountComponent: function (internalInstance, safely) {
73
+ if (process.env.NODE_ENV !== 'production') {
74
+ if (internalInstance._debugID !== 0) {
75
+ ReactInstrumentation.debugTool.onBeforeUnmountComponent(internalInstance._debugID);
76
+ }
77
+ }
78
+ ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
79
+ internalInstance.unmountComponent(safely);
80
+ if (process.env.NODE_ENV !== 'production') {
81
+ if (internalInstance._debugID !== 0) {
82
+ ReactInstrumentation.debugTool.onUnmountComponent(internalInstance._debugID);
83
+ }
84
+ }
85
+ },
86
+
87
+ /**
88
+ * Update a component using a new element.
89
+ *
90
+ * @param {ReactComponent} internalInstance
91
+ * @param {ReactElement} nextElement
92
+ * @param {ReactReconcileTransaction} transaction
93
+ * @param {object} context
94
+ * @internal
95
+ */
96
+ receiveComponent: function (internalInstance, nextElement, transaction, context) {
97
+ var prevElement = internalInstance._currentElement;
98
+
99
+ if (nextElement === prevElement && context === internalInstance._context) {
100
+ // Since elements are immutable after the owner is rendered,
101
+ // we can do a cheap identity compare here to determine if this is a
102
+ // superfluous reconcile. It's possible for state to be mutable but such
103
+ // change should trigger an update of the owner which would recreate
104
+ // the element. We explicitly check for the existence of an owner since
105
+ // it's possible for an element created outside a composite to be
106
+ // deeply mutated and reused.
107
+
108
+ // TODO: Bailing out early is just a perf optimization right?
109
+ // TODO: Removing the return statement should affect correctness?
110
+ return;
111
+ }
112
+
113
+ if (process.env.NODE_ENV !== 'production') {
114
+ if (internalInstance._debugID !== 0) {
115
+ ReactInstrumentation.debugTool.onBeforeUpdateComponent(internalInstance._debugID, nextElement);
116
+ }
117
+ }
118
+
119
+ var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement);
120
+
121
+ if (refsChanged) {
122
+ ReactRef.detachRefs(internalInstance, prevElement);
123
+ }
124
+
125
+ internalInstance.receiveComponent(nextElement, transaction, context);
126
+
127
+ if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) {
128
+ transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
129
+ }
130
+
131
+ if (process.env.NODE_ENV !== 'production') {
132
+ if (internalInstance._debugID !== 0) {
133
+ ReactInstrumentation.debugTool.onUpdateComponent(internalInstance._debugID);
134
+ }
135
+ }
136
+ },
137
+
138
+ /**
139
+ * Flush any dirty changes in a component.
140
+ *
141
+ * @param {ReactComponent} internalInstance
142
+ * @param {ReactReconcileTransaction} transaction
143
+ * @internal
144
+ */
145
+ performUpdateIfNecessary: function (internalInstance, transaction, updateBatchNumber) {
146
+ if (internalInstance._updateBatchNumber !== updateBatchNumber) {
147
+ // The component's enqueued batch number should always be the current
148
+ // batch or the following one.
149
+ process.env.NODE_ENV !== 'production' ? warning(internalInstance._updateBatchNumber == null || internalInstance._updateBatchNumber === updateBatchNumber + 1, 'performUpdateIfNecessary: Unexpected batch number (current %s, ' + 'pending %s)', updateBatchNumber, internalInstance._updateBatchNumber) : void 0;
150
+ return;
151
+ }
152
+ if (process.env.NODE_ENV !== 'production') {
153
+ if (internalInstance._debugID !== 0) {
154
+ ReactInstrumentation.debugTool.onBeforeUpdateComponent(internalInstance._debugID, internalInstance._currentElement);
155
+ }
156
+ }
157
+ internalInstance.performUpdateIfNecessary(transaction);
158
+ if (process.env.NODE_ENV !== 'production') {
159
+ if (internalInstance._debugID !== 0) {
160
+ ReactInstrumentation.debugTool.onUpdateComponent(internalInstance._debugID);
161
+ }
162
+ }
163
+ }
164
+
165
+ };
166
+
167
+ module.exports = ReactReconciler;
@@ -0,0 +1,88 @@
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
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactOwner = require('./ReactOwner');
15
+
16
+ var ReactRef = {};
17
+
18
+ function attachRef(ref, component, owner) {
19
+ if (typeof ref === 'function') {
20
+ ref(component.getPublicInstance());
21
+ } else {
22
+ // Legacy ref
23
+ ReactOwner.addComponentAsRefTo(component, ref, owner);
24
+ }
25
+ }
26
+
27
+ function detachRef(ref, component, owner) {
28
+ if (typeof ref === 'function') {
29
+ ref(null);
30
+ } else {
31
+ // Legacy ref
32
+ ReactOwner.removeComponentAsRefFrom(component, ref, owner);
33
+ }
34
+ }
35
+
36
+ ReactRef.attachRefs = function (instance, element) {
37
+ if (element === null || typeof element !== 'object') {
38
+ return;
39
+ }
40
+ var ref = element.ref;
41
+ if (ref != null) {
42
+ attachRef(ref, instance, element._owner);
43
+ }
44
+ };
45
+
46
+ ReactRef.shouldUpdateRefs = function (prevElement, nextElement) {
47
+ // If either the owner or a `ref` has changed, make sure the newest owner
48
+ // has stored a reference to `this`, and the previous owner (if different)
49
+ // has forgotten the reference to `this`. We use the element instead
50
+ // of the public this.props because the post processing cannot determine
51
+ // a ref. The ref conceptually lives on the element.
52
+
53
+ // TODO: Should this even be possible? The owner cannot change because
54
+ // it's forbidden by shouldUpdateReactComponent. The ref can change
55
+ // if you swap the keys of but not the refs. Reconsider where this check
56
+ // is made. It probably belongs where the key checking and
57
+ // instantiateReactComponent is done.
58
+
59
+ var prevRef = null;
60
+ var prevOwner = null;
61
+ if (prevElement !== null && typeof prevElement === 'object') {
62
+ prevRef = prevElement.ref;
63
+ prevOwner = prevElement._owner;
64
+ }
65
+
66
+ var nextRef = null;
67
+ var nextOwner = null;
68
+ if (nextElement !== null && typeof nextElement === 'object') {
69
+ nextRef = nextElement.ref;
70
+ nextOwner = nextElement._owner;
71
+ }
72
+
73
+ return prevRef !== nextRef ||
74
+ // If owner changes but we have an unchanged function ref, don't update refs
75
+ typeof nextRef === 'string' && nextOwner !== prevOwner;
76
+ };
77
+
78
+ ReactRef.detachRefs = function (instance, element) {
79
+ if (element === null || typeof element !== 'object') {
80
+ return;
81
+ }
82
+ var ref = element.ref;
83
+ if (ref != null) {
84
+ detachRef(ref, instance, element._owner);
85
+ }
86
+ };
87
+
88
+ module.exports = ReactRef;
@@ -0,0 +1,30 @@
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
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var _require = require('./ReactFiber'),
15
+ createFiberFromElementType = _require.createFiberFromElementType;
16
+
17
+ exports.createReifiedYield = function (yieldNode) {
18
+ var fiber = createFiberFromElementType(yieldNode.continuation, yieldNode.key);
19
+ return {
20
+ continuation: fiber,
21
+ props: yieldNode.props
22
+ };
23
+ };
24
+
25
+ exports.createUpdatedReifiedYield = function (previousYield, yieldNode) {
26
+ return {
27
+ continuation: previousYield.continuation,
28
+ props: yieldNode.props
29
+ };
30
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright 2014-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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var ReactServerBatchingStrategy = {
14
+ isBatchingUpdates: false,
15
+ batchedUpdates: function (callback) {
16
+ // Don't do anything here. During the server rendering we don't want to
17
+ // schedule any updates. We will simply ignore them.
18
+ }
19
+ };
20
+
21
+ module.exports = ReactServerBatchingStrategy;
@@ -0,0 +1,89 @@
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
+ */
10
+ 'use strict';
11
+
12
+ var _prodInvariant = require('./reactProdInvariant');
13
+
14
+ var React = require('react/lib/React');
15
+ var ReactDOMContainerInfo = require('./ReactDOMContainerInfo');
16
+ var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
17
+ var ReactInstrumentation = require('./ReactInstrumentation');
18
+ var ReactMarkupChecksum = require('./ReactMarkupChecksum');
19
+ var ReactReconciler = require('./ReactReconciler');
20
+ var ReactServerBatchingStrategy = require('./ReactServerBatchingStrategy');
21
+ var ReactServerRenderingTransaction = require('./ReactServerRenderingTransaction');
22
+ var ReactUpdates = require('./ReactUpdates');
23
+
24
+ var emptyObject = require('fbjs/lib/emptyObject');
25
+ var instantiateReactComponent = require('./instantiateReactComponent');
26
+ var invariant = require('fbjs/lib/invariant');
27
+
28
+ var pendingTransactions = 0;
29
+
30
+ /**
31
+ * @param {ReactElement} element
32
+ * @return {string} the HTML markup
33
+ */
34
+ function renderToStringImpl(element, makeStaticMarkup) {
35
+ var transaction;
36
+ try {
37
+ ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
38
+
39
+ transaction = ReactServerRenderingTransaction.getPooled(makeStaticMarkup);
40
+
41
+ pendingTransactions++;
42
+
43
+ return transaction.perform(function () {
44
+ var componentInstance = instantiateReactComponent(element, true);
45
+ var markup = ReactReconciler.mountComponent(componentInstance, transaction, null, ReactDOMContainerInfo(), emptyObject, 0 /* parentDebugID */
46
+ );
47
+ if (process.env.NODE_ENV !== 'production') {
48
+ ReactInstrumentation.debugTool.onUnmountComponent(componentInstance._debugID);
49
+ }
50
+ if (!makeStaticMarkup) {
51
+ markup = ReactMarkupChecksum.addChecksumToMarkup(markup);
52
+ }
53
+ return markup;
54
+ }, null);
55
+ } finally {
56
+ pendingTransactions--;
57
+ ReactServerRenderingTransaction.release(transaction);
58
+ // Revert to the DOM batching strategy since these two renderers
59
+ // currently share these stateful modules.
60
+ if (!pendingTransactions) {
61
+ ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Render a ReactElement to its initial HTML. This should only be used on the
68
+ * server.
69
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring
70
+ */
71
+ function renderToString(element) {
72
+ !React.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : _prodInvariant('46') : void 0;
73
+ return renderToStringImpl(element, false);
74
+ }
75
+
76
+ /**
77
+ * Similar to renderToString, except this doesn't create extra DOM attributes
78
+ * such as data-react-id that React uses internally.
79
+ * See https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup
80
+ */
81
+ function renderToStaticMarkup(element) {
82
+ !React.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : _prodInvariant('47') : void 0;
83
+ return renderToStringImpl(element, true);
84
+ }
85
+
86
+ module.exports = {
87
+ renderToString: renderToString,
88
+ renderToStaticMarkup: renderToStaticMarkup
89
+ };
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Copyright 2014-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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _assign = require('object-assign');
14
+
15
+ var PooledClass = require('./PooledClass');
16
+ var Transaction = require('./Transaction');
17
+ var ReactInstrumentation = require('./ReactInstrumentation');
18
+ var ReactServerUpdateQueue = require('./ReactServerUpdateQueue');
19
+
20
+ /**
21
+ * Executed within the scope of the `Transaction` instance. Consider these as
22
+ * being member methods, but with an implied ordering while being isolated from
23
+ * each other.
24
+ */
25
+ var TRANSACTION_WRAPPERS = [];
26
+
27
+ if (process.env.NODE_ENV !== 'production') {
28
+ TRANSACTION_WRAPPERS.push({
29
+ initialize: ReactInstrumentation.debugTool.onBeginFlush,
30
+ close: ReactInstrumentation.debugTool.onEndFlush
31
+ });
32
+ }
33
+
34
+ var noopCallbackQueue = {
35
+ enqueue: function () {}
36
+ };
37
+
38
+ /**
39
+ * @class ReactServerRenderingTransaction
40
+ * @param {boolean} renderToStaticMarkup
41
+ */
42
+ function ReactServerRenderingTransaction(renderToStaticMarkup) {
43
+ this.reinitializeTransaction();
44
+ this.renderToStaticMarkup = renderToStaticMarkup;
45
+ this.useCreateElement = false;
46
+ this.updateQueue = new ReactServerUpdateQueue(this);
47
+ }
48
+
49
+ var Mixin = {
50
+ /**
51
+ * @see Transaction
52
+ * @abstract
53
+ * @final
54
+ * @return {array} Empty list of operation wrap procedures.
55
+ */
56
+ getTransactionWrappers: function () {
57
+ return TRANSACTION_WRAPPERS;
58
+ },
59
+
60
+ /**
61
+ * @return {object} The queue to collect `onDOMReady` callbacks with.
62
+ */
63
+ getReactMountReady: function () {
64
+ return noopCallbackQueue;
65
+ },
66
+
67
+ /**
68
+ * @return {object} The queue to collect React async events.
69
+ */
70
+ getUpdateQueue: function () {
71
+ return this.updateQueue;
72
+ },
73
+
74
+ /**
75
+ * `PooledClass` looks for this, and will invoke this before allowing this
76
+ * instance to be reused.
77
+ */
78
+ destructor: function () {},
79
+
80
+ checkpoint: function () {},
81
+
82
+ rollback: function () {}
83
+ };
84
+
85
+ _assign(ReactServerRenderingTransaction.prototype, Transaction, Mixin);
86
+
87
+ PooledClass.addPoolingTo(ReactServerRenderingTransaction);
88
+
89
+ module.exports = ReactServerRenderingTransaction;