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,71 +0,0 @@
1
- /**
2
- * Copyright (c) 2015-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 ReactNative
10
- *
11
- */
12
- 'use strict';
13
-
14
- // Require ReactNativeDefaultInjection first for its side effects of setting up
15
- // the JS environment
16
-
17
- var ReactNativeComponentTree = require('./ReactNativeComponentTree');
18
- var ReactNativeDefaultInjection = require('./ReactNativeDefaultInjection');
19
-
20
- var ReactElement = require('./ReactElement');
21
- var ReactNativeMount = require('./ReactNativeMount');
22
- var ReactUpdates = require('./ReactUpdates');
23
-
24
- var findNodeHandle = require('./findNodeHandle');
25
-
26
- ReactNativeDefaultInjection.inject();
27
-
28
- var render = function (element, mountInto, callback) {
29
- return ReactNativeMount.renderComponent(element, mountInto, callback);
30
- };
31
-
32
- var ReactNative = {
33
- hasReactNativeInitialized: false,
34
- findNodeHandle: findNodeHandle,
35
- render: render,
36
- unmountComponentAtNode: ReactNativeMount.unmountComponentAtNode,
37
-
38
- /* eslint-disable camelcase */
39
- unstable_batchedUpdates: ReactUpdates.batchedUpdates,
40
- /* eslint-enable camelcase */
41
-
42
- unmountComponentAtNodeAndRemoveContainer: ReactNativeMount.unmountComponentAtNodeAndRemoveContainer
43
- };
44
-
45
- // Inject the runtime into a devtools global hook regardless of browser.
46
- // Allows for debugging when the hook is injected on the page.
47
- /* globals __REACT_DEVTOOLS_GLOBAL_HOOK__ */
48
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
49
- __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
50
- ComponentTree: {
51
- getClosestInstanceFromNode: function (node) {
52
- return ReactNativeComponentTree.getClosestInstanceFromNode(node);
53
- },
54
- getNodeFromInstance: function (inst) {
55
- // inst is an internal instance (but could be a composite)
56
- while (inst._renderedComponent) {
57
- inst = inst._renderedComponent;
58
- }
59
- if (inst) {
60
- return ReactNativeComponentTree.getNodeFromInstance(inst);
61
- } else {
62
- return null;
63
- }
64
- }
65
- },
66
- Mount: ReactNativeMount,
67
- Reconciler: require('./ReactReconciler')
68
- });
69
- }
70
-
71
- module.exports = ReactNative;
@@ -1,371 +0,0 @@
1
- /**
2
- * Copyright (c) 2015-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 ReactNativeAttributePayload
10
- *
11
- */
12
- 'use strict';
13
-
14
- var ReactNativePropRegistry = require('./ReactNativePropRegistry');
15
-
16
- var deepDiffer = require('react-native/lib/deepDiffer');
17
- var flattenStyle = require('react-native/lib/flattenStyle');
18
-
19
- var emptyObject = {};
20
-
21
- /**
22
- * Create a payload that contains all the updates between two sets of props.
23
- *
24
- * These helpers are all encapsulated into a single module, because they use
25
- * mutation as a performance optimization which leads to subtle shared
26
- * dependencies between the code paths. To avoid this mutable state leaking
27
- * across modules, I've kept them isolated to this module.
28
- */
29
-
30
- /*| boolean*/
31
-
32
-
33
- // Tracks removed keys
34
- var removedKeys = null;
35
- var removedKeyCount = 0;
36
-
37
- function defaultDiffer(prevProp, nextProp) {
38
- if (typeof nextProp !== 'object' || nextProp === null) {
39
- // Scalars have already been checked for equality
40
- return true;
41
- } else {
42
- // For objects and arrays, the default diffing algorithm is a deep compare
43
- return deepDiffer(prevProp, nextProp);
44
- }
45
- }
46
-
47
- function resolveObject(idOrObject) {
48
- if (typeof idOrObject === 'number') {
49
- return ReactNativePropRegistry.getByID(idOrObject);
50
- }
51
- return idOrObject;
52
- }
53
-
54
- function restoreDeletedValuesInNestedArray(updatePayload, node, validAttributes) {
55
- if (Array.isArray(node)) {
56
- var i = node.length;
57
- while (i-- && removedKeyCount > 0) {
58
- restoreDeletedValuesInNestedArray(updatePayload, node[i], validAttributes);
59
- }
60
- } else if (node && removedKeyCount > 0) {
61
- var obj = resolveObject(node);
62
- for (var propKey in removedKeys) {
63
- if (!removedKeys[propKey]) {
64
- continue;
65
- }
66
- var nextProp = obj[propKey];
67
- if (nextProp === undefined) {
68
- continue;
69
- }
70
-
71
- var attributeConfig = validAttributes[propKey];
72
- if (!attributeConfig) {
73
- continue; // not a valid native prop
74
- }
75
-
76
- if (typeof nextProp === 'function') {
77
- nextProp = true;
78
- }
79
- if (typeof nextProp === 'undefined') {
80
- nextProp = null;
81
- }
82
-
83
- if (typeof attributeConfig !== 'object') {
84
- // case: !Object is the default case
85
- updatePayload[propKey] = nextProp;
86
- } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') {
87
- // case: CustomAttributeConfiguration
88
- var nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp;
89
- updatePayload[propKey] = nextValue;
90
- }
91
- removedKeys[propKey] = false;
92
- removedKeyCount--;
93
- }
94
- }
95
- }
96
-
97
- function diffNestedArrayProperty(updatePayload, prevArray, nextArray, validAttributes) {
98
- var minLength = prevArray.length < nextArray.length ? prevArray.length : nextArray.length;
99
- var i;
100
- for (i = 0; i < minLength; i++) {
101
- // Diff any items in the array in the forward direction. Repeated keys
102
- // will be overwritten by later values.
103
- updatePayload = diffNestedProperty(updatePayload, prevArray[i], nextArray[i], validAttributes);
104
- }
105
- for (; i < prevArray.length; i++) {
106
- // Clear out all remaining properties.
107
- updatePayload = clearNestedProperty(updatePayload, prevArray[i], validAttributes);
108
- }
109
- for (; i < nextArray.length; i++) {
110
- // Add all remaining properties.
111
- updatePayload = addNestedProperty(updatePayload, nextArray[i], validAttributes);
112
- }
113
- return updatePayload;
114
- }
115
-
116
- function diffNestedProperty(updatePayload, prevProp, nextProp, validAttributes) {
117
-
118
- if (!updatePayload && prevProp === nextProp) {
119
- // If no properties have been added, then we can bail out quickly on object
120
- // equality.
121
- return updatePayload;
122
- }
123
-
124
- if (!prevProp || !nextProp) {
125
- if (nextProp) {
126
- return addNestedProperty(updatePayload, nextProp, validAttributes);
127
- }
128
- if (prevProp) {
129
- return clearNestedProperty(updatePayload, prevProp, validAttributes);
130
- }
131
- return updatePayload;
132
- }
133
-
134
- if (!Array.isArray(prevProp) && !Array.isArray(nextProp)) {
135
- // Both are leaves, we can diff the leaves.
136
- return diffProperties(updatePayload, resolveObject(prevProp), resolveObject(nextProp), validAttributes);
137
- }
138
-
139
- if (Array.isArray(prevProp) && Array.isArray(nextProp)) {
140
- // Both are arrays, we can diff the arrays.
141
- return diffNestedArrayProperty(updatePayload, prevProp, nextProp, validAttributes);
142
- }
143
-
144
- if (Array.isArray(prevProp)) {
145
- return diffProperties(updatePayload,
146
- // $FlowFixMe - We know that this is always an object when the input is.
147
- flattenStyle(prevProp),
148
- // $FlowFixMe - We know that this isn't an array because of above flow.
149
- resolveObject(nextProp), validAttributes);
150
- }
151
-
152
- return diffProperties(updatePayload, resolveObject(prevProp),
153
- // $FlowFixMe - We know that this is always an object when the input is.
154
- flattenStyle(nextProp), validAttributes);
155
- }
156
-
157
- /**
158
- * addNestedProperty takes a single set of props and valid attribute
159
- * attribute configurations. It processes each prop and adds it to the
160
- * updatePayload.
161
- */
162
- function addNestedProperty(updatePayload, nextProp, validAttributes) {
163
- if (!nextProp) {
164
- return updatePayload;
165
- }
166
-
167
- if (!Array.isArray(nextProp)) {
168
- // Add each property of the leaf.
169
- return addProperties(updatePayload, resolveObject(nextProp), validAttributes);
170
- }
171
-
172
- for (var i = 0; i < nextProp.length; i++) {
173
- // Add all the properties of the array.
174
- updatePayload = addNestedProperty(updatePayload, nextProp[i], validAttributes);
175
- }
176
-
177
- return updatePayload;
178
- }
179
-
180
- /**
181
- * clearNestedProperty takes a single set of props and valid attributes. It
182
- * adds a null sentinel to the updatePayload, for each prop key.
183
- */
184
- function clearNestedProperty(updatePayload, prevProp, validAttributes) {
185
- if (!prevProp) {
186
- return updatePayload;
187
- }
188
-
189
- if (!Array.isArray(prevProp)) {
190
- // Add each property of the leaf.
191
- return clearProperties(updatePayload, resolveObject(prevProp), validAttributes);
192
- }
193
-
194
- for (var i = 0; i < prevProp.length; i++) {
195
- // Add all the properties of the array.
196
- updatePayload = clearNestedProperty(updatePayload, prevProp[i], validAttributes);
197
- }
198
- return updatePayload;
199
- }
200
-
201
- /**
202
- * diffProperties takes two sets of props and a set of valid attributes
203
- * and write to updatePayload the values that changed or were deleted.
204
- * If no updatePayload is provided, a new one is created and returned if
205
- * anything changed.
206
- */
207
- function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
208
- var attributeConfig;
209
- var nextProp;
210
- var prevProp;
211
-
212
- for (var propKey in nextProps) {
213
- attributeConfig = validAttributes[propKey];
214
- if (!attributeConfig) {
215
- continue; // not a valid native prop
216
- }
217
-
218
- prevProp = prevProps[propKey];
219
- nextProp = nextProps[propKey];
220
-
221
- // functions are converted to booleans as markers that the associated
222
- // events should be sent from native.
223
- if (typeof nextProp === 'function') {
224
- nextProp = true;
225
- // If nextProp is not a function, then don't bother changing prevProp
226
- // since nextProp will win and go into the updatePayload regardless.
227
- if (typeof prevProp === 'function') {
228
- prevProp = true;
229
- }
230
- }
231
-
232
- // An explicit value of undefined is treated as a null because it overrides
233
- // any other preceeding value.
234
- if (typeof nextProp === 'undefined') {
235
- nextProp = null;
236
- if (typeof prevProp === 'undefined') {
237
- prevProp = null;
238
- }
239
- }
240
-
241
- if (removedKeys) {
242
- removedKeys[propKey] = false;
243
- }
244
-
245
- if (updatePayload && updatePayload[propKey] !== undefined) {
246
- // Something else already triggered an update to this key because another
247
- // value diffed. Since we're now later in the nested arrays our value is
248
- // more important so we need to calculate it and override the existing
249
- // value. It doesn't matter if nothing changed, we'll set it anyway.
250
-
251
- // Pattern match on: attributeConfig
252
- if (typeof attributeConfig !== 'object') {
253
- // case: !Object is the default case
254
- updatePayload[propKey] = nextProp;
255
- } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') {
256
- // case: CustomAttributeConfiguration
257
- var nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp;
258
- updatePayload[propKey] = nextValue;
259
- }
260
- continue;
261
- }
262
-
263
- if (prevProp === nextProp) {
264
- continue; // nothing changed
265
- }
266
-
267
- // Pattern match on: attributeConfig
268
- if (typeof attributeConfig !== 'object') {
269
- // case: !Object is the default case
270
- if (defaultDiffer(prevProp, nextProp)) {
271
- // a normal leaf has changed
272
- (updatePayload || (updatePayload = {}))[propKey] = nextProp;
273
- }
274
- } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') {
275
- // case: CustomAttributeConfiguration
276
- var shouldUpdate = prevProp === undefined || (typeof attributeConfig.diff === 'function' ? attributeConfig.diff(prevProp, nextProp) : defaultDiffer(prevProp, nextProp));
277
- if (shouldUpdate) {
278
- nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp;
279
- (updatePayload || (updatePayload = {}))[propKey] = nextValue;
280
- }
281
- } else {
282
- // default: fallthrough case when nested properties are defined
283
- removedKeys = null;
284
- removedKeyCount = 0;
285
- // We think that attributeConfig is not CustomAttributeConfiguration at
286
- // this point so we assume it must be AttributeConfiguration.
287
- // $FlowFixMe
288
- updatePayload = diffNestedProperty(updatePayload, prevProp, nextProp, attributeConfig);
289
- if (removedKeyCount > 0 && updatePayload) {
290
- restoreDeletedValuesInNestedArray(updatePayload, nextProp, attributeConfig);
291
- removedKeys = null;
292
- }
293
- }
294
- }
295
-
296
- // Also iterate through all the previous props to catch any that have been
297
- // removed and make sure native gets the signal so it can reset them to the
298
- // default.
299
- for (propKey in prevProps) {
300
- if (nextProps[propKey] !== undefined) {
301
- continue; // we've already covered this key in the previous pass
302
- }
303
- attributeConfig = validAttributes[propKey];
304
- if (!attributeConfig) {
305
- continue; // not a valid native prop
306
- }
307
-
308
- if (updatePayload && updatePayload[propKey] !== undefined) {
309
- // This was already updated to a diff result earlier.
310
- continue;
311
- }
312
-
313
- prevProp = prevProps[propKey];
314
- if (prevProp === undefined) {
315
- continue; // was already empty anyway
316
- }
317
- // Pattern match on: attributeConfig
318
- if (typeof attributeConfig !== 'object' || typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') {
319
-
320
- // case: CustomAttributeConfiguration | !Object
321
- // Flag the leaf property for removal by sending a sentinel.
322
- (updatePayload || (updatePayload = {}))[propKey] = null;
323
- if (!removedKeys) {
324
- removedKeys = {};
325
- }
326
- if (!removedKeys[propKey]) {
327
- removedKeys[propKey] = true;
328
- removedKeyCount++;
329
- }
330
- } else {
331
- // default:
332
- // This is a nested attribute configuration where all the properties
333
- // were removed so we need to go through and clear out all of them.
334
- updatePayload = clearNestedProperty(updatePayload, prevProp, attributeConfig);
335
- }
336
- }
337
- return updatePayload;
338
- }
339
-
340
- /**
341
- * addProperties adds all the valid props to the payload after being processed.
342
- */
343
- function addProperties(updatePayload, props, validAttributes) {
344
- // TODO: Fast path
345
- return diffProperties(updatePayload, emptyObject, props, validAttributes);
346
- }
347
-
348
- /**
349
- * clearProperties clears all the previous props by adding a null sentinel
350
- * to the payload for each valid key.
351
- */
352
- function clearProperties(updatePayload, prevProps, validAttributes) {
353
- // TODO: Fast path
354
- return diffProperties(updatePayload, prevProps, emptyObject, validAttributes);
355
- }
356
-
357
- var ReactNativeAttributePayload = {
358
-
359
- create: function (props, validAttributes) {
360
- return addProperties(null, // updatePayload
361
- props, validAttributes);
362
- },
363
-
364
- diff: function (prevProps, nextProps, validAttributes) {
365
- return diffProperties(null, // updatePayload
366
- prevProps, nextProps, validAttributes);
367
- }
368
-
369
- };
370
-
371
- module.exports = ReactNativeAttributePayload;
@@ -1,198 +0,0 @@
1
- /**
2
- * Copyright (c) 2015-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 ReactNativeBaseComponent
10
- *
11
- */
12
- 'use strict';
13
-
14
- var _assign = require('object-assign');
15
-
16
- var NativeMethodsMixin = require('./NativeMethodsMixin');
17
- var ReactNativeAttributePayload = require('./ReactNativeAttributePayload');
18
- var ReactNativeComponentTree = require('./ReactNativeComponentTree');
19
- var ReactNativeEventEmitter = require('./ReactNativeEventEmitter');
20
- var ReactNativeTagHandles = require('./ReactNativeTagHandles');
21
- var ReactMultiChild = require('./ReactMultiChild');
22
- var UIManager = require('react-native/lib/UIManager');
23
-
24
- var deepFreezeAndThrowOnMutationInDev = require('react-native/lib/deepFreezeAndThrowOnMutationInDev');
25
-
26
- var registrationNames = ReactNativeEventEmitter.registrationNames;
27
- var putListener = ReactNativeEventEmitter.putListener;
28
- var deleteListener = ReactNativeEventEmitter.deleteListener;
29
- var deleteAllListeners = ReactNativeEventEmitter.deleteAllListeners;
30
-
31
- // require('UIManagerStatTracker').install(); // uncomment to enable
32
-
33
- /**
34
- * @constructor ReactNativeBaseComponent
35
- * @extends ReactComponent
36
- * @extends ReactMultiChild
37
- * @param {!object} UIKit View Configuration.
38
- */
39
- var ReactNativeBaseComponent = function (viewConfig) {
40
- this.viewConfig = viewConfig;
41
- };
42
-
43
- /**
44
- * Mixin for containers that contain UIViews. NOTE: markup is rendered markup
45
- * which is a `viewID` ... see the return value for `mountComponent` !
46
- */
47
- ReactNativeBaseComponent.Mixin = {
48
- getPublicInstance: function () {
49
- // TODO: This should probably use a composite wrapper
50
- return this;
51
- },
52
-
53
- unmountComponent: function () {
54
- ReactNativeComponentTree.uncacheNode(this);
55
- deleteAllListeners(this);
56
- this.unmountChildren();
57
- this._rootNodeID = 0;
58
- },
59
-
60
- /**
61
- * Every native component is responsible for allocating its own `tag`, and
62
- * issuing the native `createView` command. But it is not responsible for
63
- * recording the fact that its own `rootNodeID` is associated with a
64
- * `nodeHandle`. Only the code that actually adds its `nodeHandle` (`tag`) as
65
- * a child of a container can confidently record that in
66
- * `ReactNativeTagHandles`.
67
- */
68
- initializeChildren: function (children, containerTag, transaction, context) {
69
- var mountImages = this.mountChildren(children, transaction, context);
70
- // In a well balanced tree, half of the nodes are in the bottom row and have
71
- // no children - let's avoid calling out to the native bridge for a large
72
- // portion of the children.
73
- if (mountImages.length) {
74
-
75
- // TODO: Pool these per platform view class. Reusing the `mountImages`
76
- // array would likely be a jit deopt.
77
- var createdTags = [];
78
- for (var i = 0, l = mountImages.length; i < l; i++) {
79
- var mountImage = mountImages[i];
80
- var childTag = mountImage;
81
- createdTags[i] = childTag;
82
- }
83
- UIManager.setChildren(containerTag, createdTags);
84
- }
85
- },
86
-
87
- /**
88
- * Updates the component's currently mounted representation.
89
- *
90
- * @param {object} nextElement
91
- * @param {ReactReconcileTransaction} transaction
92
- * @param {object} context
93
- * @internal
94
- */
95
- receiveComponent: function (nextElement, transaction, context) {
96
- var prevElement = this._currentElement;
97
- this._currentElement = nextElement;
98
-
99
- if (process.env.NODE_ENV !== 'production') {
100
- for (var key in this.viewConfig.validAttributes) {
101
- if (nextElement.props.hasOwnProperty(key)) {
102
- deepFreezeAndThrowOnMutationInDev(nextElement.props[key]);
103
- }
104
- }
105
- }
106
-
107
- var updatePayload = ReactNativeAttributePayload.diff(prevElement.props, nextElement.props, this.viewConfig.validAttributes);
108
-
109
- if (updatePayload) {
110
- UIManager.updateView(this._rootNodeID, this.viewConfig.uiViewClassName, updatePayload);
111
- }
112
-
113
- this._reconcileListenersUponUpdate(prevElement.props, nextElement.props);
114
- this.updateChildren(nextElement.props.children, transaction, context);
115
- },
116
-
117
- /**
118
- * @param {object} initialProps Native component props.
119
- */
120
- _registerListenersUponCreation: function (initialProps) {
121
- for (var key in initialProps) {
122
- // NOTE: The check for `!props[key]`, is only possible because this method
123
- // registers listeners the *first* time a component is created.
124
- if (registrationNames[key] && initialProps[key]) {
125
- var listener = initialProps[key];
126
- putListener(this, key, listener);
127
- }
128
- }
129
- },
130
-
131
- /**
132
- * Reconciles event listeners, adding or removing if necessary.
133
- * @param {object} prevProps Native component props including events.
134
- * @param {object} nextProps Next native component props including events.
135
- */
136
- _reconcileListenersUponUpdate: function (prevProps, nextProps) {
137
- for (var key in nextProps) {
138
- if (registrationNames[key] && nextProps[key] !== prevProps[key]) {
139
- if (nextProps[key]) {
140
- putListener(this, key, nextProps[key]);
141
- } else {
142
- deleteListener(this, key);
143
- }
144
- }
145
- }
146
- },
147
-
148
- /**
149
- * Currently this still uses IDs for reconciliation so this can return null.
150
- *
151
- * @return {null} Null.
152
- */
153
- getHostNode: function () {
154
- return this._rootNodeID;
155
- },
156
-
157
- /**
158
- * @param {ReactNativeReconcileTransaction} transaction
159
- * @param {?ReactNativeBaseComponent} the parent component instance
160
- * @param {?object} info about the host container
161
- * @param {object} context
162
- * @return {string} Unique iOS view tag.
163
- */
164
- mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
165
- var tag = ReactNativeTagHandles.allocateTag();
166
-
167
- this._rootNodeID = tag;
168
- this._hostParent = hostParent;
169
- this._hostContainerInfo = hostContainerInfo;
170
-
171
- if (process.env.NODE_ENV !== 'production') {
172
- for (var key in this.viewConfig.validAttributes) {
173
- if (this._currentElement.props.hasOwnProperty(key)) {
174
- deepFreezeAndThrowOnMutationInDev(this._currentElement.props[key]);
175
- }
176
- }
177
- }
178
-
179
- var updatePayload = ReactNativeAttributePayload.create(this._currentElement.props, this.viewConfig.validAttributes);
180
-
181
- var nativeTopRootTag = hostContainerInfo._tag;
182
- UIManager.createView(tag, this.viewConfig.uiViewClassName, nativeTopRootTag, updatePayload);
183
-
184
- ReactNativeComponentTree.precacheNode(this, tag);
185
-
186
- this._registerListenersUponCreation(this._currentElement.props);
187
- this.initializeChildren(this._currentElement.props.children, tag, transaction, context);
188
- return tag;
189
- }
190
- };
191
-
192
- /**
193
- * Order of mixins is important. ReactNativeBaseComponent overrides methods in
194
- * ReactMultiChild.
195
- */
196
- _assign(ReactNativeBaseComponent.prototype, ReactMultiChild.Mixin, ReactNativeBaseComponent.Mixin, NativeMethodsMixin);
197
-
198
- module.exports = ReactNativeBaseComponent;