react 15.3.2 → 15.4.0-rc.1

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 (189) hide show
  1. package/dist/react-with-addons.js +3898 -21383
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2672 -19494
  4. package/dist/react.min.js +2 -6
  5. package/lib/LinkedStateMixin.js +1 -2
  6. package/lib/PooledClass.js +3 -0
  7. package/lib/ReactAddonsDOMDependencies.js +36 -0
  8. package/lib/ReactAddonsDOMDependenciesUMDShim.js +32 -0
  9. package/lib/ReactCSSTransitionGroup.js +60 -42
  10. package/lib/ReactCSSTransitionGroupChild.js +2 -2
  11. package/lib/ReactClass.js +38 -53
  12. package/lib/ReactComponentTreeHook.js +84 -100
  13. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +5 -7
  14. package/lib/ReactCurrentOwner.js +1 -1
  15. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +6 -4
  16. package/lib/ReactElement.js +6 -13
  17. package/lib/ReactElementSymbol.js +20 -0
  18. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +4 -9
  19. package/lib/ReactElementValidator.js +1 -2
  20. package/lib/ReactPropTypeLocationNames.js +1 -0
  21. package/lib/ReactPropTypeLocations.js +2 -11
  22. package/lib/ReactPropTypes.js +5 -2
  23. package/lib/ReactPropTypesSecret.js +1 -0
  24. package/lib/ReactTransitionEvents.js +1 -1
  25. package/lib/ReactTransitionGroup.js +145 -141
  26. package/lib/ReactUMDEntry.js +11 -5
  27. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +4 -6
  28. package/lib/ReactVersion.js +1 -1
  29. package/lib/ReactWithAddons.js +15 -2
  30. package/lib/ReactWithAddonsUMDEntry.js +11 -5
  31. package/lib/canDefineProperty.js +2 -0
  32. package/lib/traverseAllChildren.js +11 -2
  33. package/lib/update.js +6 -7
  34. package/package.json +1 -1
  35. package/lib/AutoFocusUtils.js +0 -24
  36. package/lib/BeforeInputEventPlugin.js +0 -390
  37. package/lib/CSSProperty.js +0 -148
  38. package/lib/CSSPropertyOperations.js +0 -205
  39. package/lib/CallbackQueue.js +0 -106
  40. package/lib/ChangeEventPlugin.js +0 -325
  41. package/lib/DOMChildrenOperations.js +0 -194
  42. package/lib/DOMLazyTree.js +0 -118
  43. package/lib/DOMProperty.js +0 -206
  44. package/lib/DOMPropertyOperations.js +0 -221
  45. package/lib/Danger.js +0 -48
  46. package/lib/DefaultEventPluginOrder.js +0 -27
  47. package/lib/DisabledInputUtils.js +0 -50
  48. package/lib/EnterLeaveEventPlugin.js +0 -105
  49. package/lib/EventConstants.js +0 -97
  50. package/lib/EventPluginHub.js +0 -251
  51. package/lib/EventPluginRegistry.js +0 -247
  52. package/lib/EventPluginUtils.js +0 -229
  53. package/lib/EventPropagators.js +0 -137
  54. package/lib/FallbackCompositionState.js +0 -95
  55. package/lib/HTMLDOMPropertyConfig.js +0 -212
  56. package/lib/LinkedValueUtils.js +0 -136
  57. package/lib/NativeMethodsMixin.js +0 -167
  58. package/lib/ReactBrowserEventEmitter.js +0 -330
  59. package/lib/ReactChildReconciler.js +0 -154
  60. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  61. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  62. package/lib/ReactComponentEnvironment.js +0 -45
  63. package/lib/ReactComponentTreeTestUtils.js +0 -87
  64. package/lib/ReactCompositeComponent.js +0 -904
  65. package/lib/ReactDOM.js +0 -110
  66. package/lib/ReactDOMButton.js +0 -24
  67. package/lib/ReactDOMComponent.js +0 -1006
  68. package/lib/ReactDOMComponentTree.js +0 -188
  69. package/lib/ReactDOMContainerInfo.js +0 -33
  70. package/lib/ReactDOMEmptyComponent.js +0 -60
  71. package/lib/ReactDOMFiber.js +0 -76
  72. package/lib/ReactDOMIDOperations.js +0 -34
  73. package/lib/ReactDOMInput.js +0 -269
  74. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  75. package/lib/ReactDOMOption.js +0 -123
  76. package/lib/ReactDOMSelect.js +0 -201
  77. package/lib/ReactDOMSelection.js +0 -212
  78. package/lib/ReactDOMServer.js +0 -26
  79. package/lib/ReactDOMTextComponent.js +0 -164
  80. package/lib/ReactDOMTextarea.js +0 -155
  81. package/lib/ReactDOMTreeTraversal.js +0 -136
  82. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  83. package/lib/ReactDebugTool.js +0 -301
  84. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  85. package/lib/ReactDefaultInjection.js +0 -84
  86. package/lib/ReactEmptyComponent.js +0 -30
  87. package/lib/ReactErrorUtils.js +0 -76
  88. package/lib/ReactEventEmitterMixin.js +0 -33
  89. package/lib/ReactEventListener.js +0 -157
  90. package/lib/ReactFeatureFlags.js +0 -22
  91. package/lib/ReactHostComponent.js +0 -76
  92. package/lib/ReactHostOperationHistoryHook.js +0 -37
  93. package/lib/ReactInjection.js +0 -36
  94. package/lib/ReactInputSelection.js +0 -124
  95. package/lib/ReactInstanceHandles.js +0 -302
  96. package/lib/ReactInstanceMap.js +0 -48
  97. package/lib/ReactInstrumentation.js +0 -21
  98. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  99. package/lib/ReactMarkupChecksum.js +0 -50
  100. package/lib/ReactMount.js +0 -534
  101. package/lib/ReactMultiChild.js +0 -451
  102. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  103. package/lib/ReactNative.js +0 -71
  104. package/lib/ReactNativeAttributePayload.js +0 -371
  105. package/lib/ReactNativeBaseComponent.js +0 -198
  106. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  107. package/lib/ReactNativeComponentEnvironment.js +0 -31
  108. package/lib/ReactNativeComponentTree.js +0 -68
  109. package/lib/ReactNativeContainerInfo.js +0 -21
  110. package/lib/ReactNativeDOMIDOperations.js +0 -79
  111. package/lib/ReactNativeDefaultInjection.js +0 -101
  112. package/lib/ReactNativeEventEmitter.js +0 -191
  113. package/lib/ReactNativeEventPluginOrder.js +0 -16
  114. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  115. package/lib/ReactNativeMount.js +0 -193
  116. package/lib/ReactNativePropRegistry.js +0 -52
  117. package/lib/ReactNativeReconcileTransaction.js +0 -129
  118. package/lib/ReactNativeTagHandles.js +0 -56
  119. package/lib/ReactNativeTextComponent.js +0 -71
  120. package/lib/ReactNativeTreeTraversal.js +0 -127
  121. package/lib/ReactNodeTypes.js +0 -40
  122. package/lib/ReactNoop.js +0 -173
  123. package/lib/ReactOwner.js +0 -94
  124. package/lib/ReactPerf.js +0 -494
  125. package/lib/ReactReconcileTransaction.js +0 -178
  126. package/lib/ReactReconciler.js +0 -168
  127. package/lib/ReactRef.js +0 -80
  128. package/lib/ReactServerBatchingStrategy.js +0 -22
  129. package/lib/ReactServerRendering.js +0 -90
  130. package/lib/ReactServerRenderingTransaction.js +0 -90
  131. package/lib/ReactServerUpdateQueue.js +0 -141
  132. package/lib/ReactSimpleEmptyComponent.js +0 -37
  133. package/lib/ReactTestMount.js +0 -126
  134. package/lib/ReactTestReconcileTransaction.js +0 -121
  135. package/lib/ReactTestRenderer.js +0 -144
  136. package/lib/ReactTestUtils.js +0 -518
  137. package/lib/ReactUpdateQueue.js +0 -226
  138. package/lib/ReactUpdates.js +0 -251
  139. package/lib/ResponderEventPlugin.js +0 -510
  140. package/lib/ResponderSyntheticEvent.js +0 -39
  141. package/lib/ResponderTouchHistoryStore.js +0 -184
  142. package/lib/SVGDOMPropertyConfig.js +0 -302
  143. package/lib/SelectEventPlugin.js +0 -196
  144. package/lib/SimpleEventPlugin.js +0 -635
  145. package/lib/SyntheticAnimationEvent.js +0 -39
  146. package/lib/SyntheticClipboardEvent.js +0 -38
  147. package/lib/SyntheticCompositionEvent.js +0 -36
  148. package/lib/SyntheticDragEvent.js +0 -36
  149. package/lib/SyntheticEvent.js +0 -268
  150. package/lib/SyntheticFocusEvent.js +0 -36
  151. package/lib/SyntheticInputEvent.js +0 -37
  152. package/lib/SyntheticKeyboardEvent.js +0 -84
  153. package/lib/SyntheticMouseEvent.js +0 -72
  154. package/lib/SyntheticTouchEvent.js +0 -45
  155. package/lib/SyntheticTransitionEvent.js +0 -39
  156. package/lib/SyntheticUIEvent.js +0 -59
  157. package/lib/SyntheticWheelEvent.js +0 -54
  158. package/lib/TapEventPlugin.js +0 -110
  159. package/lib/TouchHistoryMath.js +0 -99
  160. package/lib/Transaction.js +0 -233
  161. package/lib/ViewportMetrics.js +0 -27
  162. package/lib/accumulate.js +0 -46
  163. package/lib/accumulateInto.js +0 -58
  164. package/lib/adler32.js +0 -44
  165. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  166. package/lib/createReactNativeComponentClass.js +0 -42
  167. package/lib/dangerousStyleValue.js +0 -79
  168. package/lib/escapeTextContentForBrowser.js +0 -123
  169. package/lib/findDOMNode.js +0 -60
  170. package/lib/findNodeHandle.js +0 -91
  171. package/lib/forEachAccumulated.js +0 -31
  172. package/lib/getEventCharCode.js +0 -50
  173. package/lib/getEventKey.js +0 -102
  174. package/lib/getEventModifierState.js +0 -43
  175. package/lib/getEventTarget.js +0 -35
  176. package/lib/getHostComponentFromComposite.js +0 -30
  177. package/lib/getNodeForCharacterOffset.js +0 -74
  178. package/lib/getTestDocument.js +0 -21
  179. package/lib/getTextContentAccessor.js +0 -33
  180. package/lib/getVendorPrefixedEventName.js +0 -101
  181. package/lib/instantiateReactComponent.js +0 -119
  182. package/lib/isEventSupported.js +0 -60
  183. package/lib/isTextInputElement.js +0 -51
  184. package/lib/quoteAttributeValueForBrowser.js +0 -26
  185. package/lib/reactComponentExpect.js +0 -217
  186. package/lib/setInnerHTML.js +0 -98
  187. package/lib/setTextContent.js +0 -48
  188. package/lib/shouldUpdateReactComponent.js +0 -42
  189. package/lib/validateDOMNesting.js +0 -382
@@ -1,37 +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 ReactHostOperationHistoryHook
10
- */
11
-
12
- 'use strict';
13
-
14
- var history = [];
15
-
16
- var ReactHostOperationHistoryHook = {
17
- onHostOperation: function (debugID, type, payload) {
18
- history.push({
19
- instanceID: debugID,
20
- type: type,
21
- payload: payload
22
- });
23
- },
24
- clearHistory: function () {
25
- if (ReactHostOperationHistoryHook._preventClearing) {
26
- // Should only be used for tests.
27
- return;
28
- }
29
-
30
- history = [];
31
- },
32
- getHistory: function () {
33
- return history;
34
- }
35
- };
36
-
37
- module.exports = ReactHostOperationHistoryHook;
@@ -1,36 +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 ReactInjection
10
- */
11
-
12
- 'use strict';
13
-
14
- var DOMProperty = require('./DOMProperty');
15
- var EventPluginHub = require('./EventPluginHub');
16
- var EventPluginUtils = require('./EventPluginUtils');
17
- var ReactComponentEnvironment = require('./ReactComponentEnvironment');
18
- var ReactClass = require('./ReactClass');
19
- var ReactEmptyComponent = require('./ReactEmptyComponent');
20
- var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
21
- var ReactHostComponent = require('./ReactHostComponent');
22
- var ReactUpdates = require('./ReactUpdates');
23
-
24
- var ReactInjection = {
25
- Component: ReactComponentEnvironment.injection,
26
- Class: ReactClass.injection,
27
- DOMProperty: DOMProperty.injection,
28
- EmptyComponent: ReactEmptyComponent.injection,
29
- EventPluginHub: EventPluginHub.injection,
30
- EventPluginUtils: EventPluginUtils.injection,
31
- EventEmitter: ReactBrowserEventEmitter.injection,
32
- HostComponent: ReactHostComponent.injection,
33
- Updates: ReactUpdates.injection
34
- };
35
-
36
- module.exports = ReactInjection;
@@ -1,124 +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 ReactInputSelection
10
- */
11
-
12
- 'use strict';
13
-
14
- var ReactDOMSelection = require('./ReactDOMSelection');
15
-
16
- var containsNode = require('fbjs/lib/containsNode');
17
- var focusNode = require('fbjs/lib/focusNode');
18
- var getActiveElement = require('fbjs/lib/getActiveElement');
19
-
20
- function isInDocument(node) {
21
- return containsNode(document.documentElement, node);
22
- }
23
-
24
- /**
25
- * @ReactInputSelection: React input selection module. Based on Selection.js,
26
- * but modified to be suitable for react and has a couple of bug fixes (doesn't
27
- * assume buttons have range selections allowed).
28
- * Input selection module for React.
29
- */
30
- var ReactInputSelection = {
31
-
32
- hasSelectionCapabilities: function (elem) {
33
- var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
34
- return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
35
- },
36
-
37
- getSelectionInformation: function () {
38
- var focusedElem = getActiveElement();
39
- return {
40
- focusedElem: focusedElem,
41
- selectionRange: ReactInputSelection.hasSelectionCapabilities(focusedElem) ? ReactInputSelection.getSelection(focusedElem) : null
42
- };
43
- },
44
-
45
- /**
46
- * @restoreSelection: If any selection information was potentially lost,
47
- * restore it. This is useful when performing operations that could remove dom
48
- * nodes and place them back in, resulting in focus being lost.
49
- */
50
- restoreSelection: function (priorSelectionInformation) {
51
- var curFocusedElem = getActiveElement();
52
- var priorFocusedElem = priorSelectionInformation.focusedElem;
53
- var priorSelectionRange = priorSelectionInformation.selectionRange;
54
- if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
55
- if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
56
- ReactInputSelection.setSelection(priorFocusedElem, priorSelectionRange);
57
- }
58
- focusNode(priorFocusedElem);
59
- }
60
- },
61
-
62
- /**
63
- * @getSelection: Gets the selection bounds of a focused textarea, input or
64
- * contentEditable node.
65
- * -@input: Look up selection bounds of this input
66
- * -@return {start: selectionStart, end: selectionEnd}
67
- */
68
- getSelection: function (input) {
69
- var selection;
70
-
71
- if ('selectionStart' in input) {
72
- // Modern browser with input or textarea.
73
- selection = {
74
- start: input.selectionStart,
75
- end: input.selectionEnd
76
- };
77
- } else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
78
- // IE8 input.
79
- var range = document.selection.createRange();
80
- // There can only be one selection per document in IE, so it must
81
- // be in our element.
82
- if (range.parentElement() === input) {
83
- selection = {
84
- start: -range.moveStart('character', -input.value.length),
85
- end: -range.moveEnd('character', -input.value.length)
86
- };
87
- }
88
- } else {
89
- // Content editable or old IE textarea.
90
- selection = ReactDOMSelection.getOffsets(input);
91
- }
92
-
93
- return selection || { start: 0, end: 0 };
94
- },
95
-
96
- /**
97
- * @setSelection: Sets the selection bounds of a textarea or input and focuses
98
- * the input.
99
- * -@input Set selection bounds of this input or textarea
100
- * -@offsets Object of same form that is returned from get*
101
- */
102
- setSelection: function (input, offsets) {
103
- var start = offsets.start;
104
- var end = offsets.end;
105
- if (end === undefined) {
106
- end = start;
107
- }
108
-
109
- if ('selectionStart' in input) {
110
- input.selectionStart = start;
111
- input.selectionEnd = Math.min(end, input.value.length);
112
- } else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
113
- var range = input.createTextRange();
114
- range.collapse(true);
115
- range.moveStart('character', start);
116
- range.moveEnd('character', end - start);
117
- range.select();
118
- } else {
119
- ReactDOMSelection.setOffsets(input, offsets);
120
- }
121
- }
122
- };
123
-
124
- module.exports = ReactInputSelection;
@@ -1,302 +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 ReactInstanceHandles
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant');
15
-
16
- var invariant = require('fbjs/lib/invariant');
17
-
18
- var SEPARATOR = '.';
19
- var SEPARATOR_LENGTH = SEPARATOR.length;
20
-
21
- /**
22
- * Maximum depth of traversals before we consider the possibility of a bad ID.
23
- */
24
- var MAX_TREE_DEPTH = 10000;
25
-
26
- /**
27
- * Creates a DOM ID prefix to use when mounting React components.
28
- *
29
- * @param {number} index A unique integer
30
- * @return {string} React root ID.
31
- * @internal
32
- */
33
- function getReactRootIDString(index) {
34
- return SEPARATOR + index.toString(36);
35
- }
36
-
37
- /**
38
- * Checks if a character in the supplied ID is a separator or the end.
39
- *
40
- * @param {string} id A React DOM ID.
41
- * @param {number} index Index of the character to check.
42
- * @return {boolean} True if the character is a separator or end of the ID.
43
- * @private
44
- */
45
- function isBoundary(id, index) {
46
- return id.charAt(index) === SEPARATOR || index === id.length;
47
- }
48
-
49
- /**
50
- * Checks if the supplied string is a valid React DOM ID.
51
- *
52
- * @param {string} id A React DOM ID, maybe.
53
- * @return {boolean} True if the string is a valid React DOM ID.
54
- * @private
55
- */
56
- function isValidID(id) {
57
- return id === '' || id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR;
58
- }
59
-
60
- /**
61
- * Checks if the first ID is an ancestor of or equal to the second ID.
62
- *
63
- * @param {string} ancestorID
64
- * @param {string} descendantID
65
- * @return {boolean} True if `ancestorID` is an ancestor of `descendantID`.
66
- * @internal
67
- */
68
- function isAncestorIDOf(ancestorID, descendantID) {
69
- return descendantID.indexOf(ancestorID) === 0 && isBoundary(descendantID, ancestorID.length);
70
- }
71
-
72
- /**
73
- * Gets the parent ID of the supplied React DOM ID, `id`.
74
- *
75
- * @param {string} id ID of a component.
76
- * @return {string} ID of the parent, or an empty string.
77
- * @private
78
- */
79
- function getParentID(id) {
80
- return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
81
- }
82
-
83
- /**
84
- * Gets the next DOM ID on the tree path from the supplied `ancestorID` to the
85
- * supplied `destinationID`. If they are equal, the ID is returned.
86
- *
87
- * @param {string} ancestorID ID of an ancestor node of `destinationID`.
88
- * @param {string} destinationID ID of the destination node.
89
- * @return {string} Next ID on the path from `ancestorID` to `destinationID`.
90
- * @private
91
- */
92
- function getNextDescendantID(ancestorID, destinationID) {
93
- !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : _prodInvariant('112', ancestorID, destinationID) : void 0;
94
- !isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : _prodInvariant('113', ancestorID, destinationID) : void 0;
95
- if (ancestorID === destinationID) {
96
- return ancestorID;
97
- }
98
- // Skip over the ancestor and the immediate separator. Traverse until we hit
99
- // another separator or we reach the end of `destinationID`.
100
- var start = ancestorID.length + SEPARATOR_LENGTH;
101
- var i;
102
- for (i = start; i < destinationID.length; i++) {
103
- if (isBoundary(destinationID, i)) {
104
- break;
105
- }
106
- }
107
- return destinationID.substr(0, i);
108
- }
109
-
110
- /**
111
- * Gets the nearest common ancestor ID of two IDs.
112
- *
113
- * Using this ID scheme, the nearest common ancestor ID is the longest common
114
- * prefix of the two IDs that immediately preceded a "marker" in both strings.
115
- *
116
- * @param {string} oneID
117
- * @param {string} twoID
118
- * @return {string} Nearest common ancestor ID, or the empty string if none.
119
- * @private
120
- */
121
- function getFirstCommonAncestorID(oneID, twoID) {
122
- var minLength = Math.min(oneID.length, twoID.length);
123
- if (minLength === 0) {
124
- return '';
125
- }
126
- var lastCommonMarkerIndex = 0;
127
- // Use `<=` to traverse until the "EOL" of the shorter string.
128
- for (var i = 0; i <= minLength; i++) {
129
- if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
130
- lastCommonMarkerIndex = i;
131
- } else if (oneID.charAt(i) !== twoID.charAt(i)) {
132
- break;
133
- }
134
- }
135
- var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
136
- !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : _prodInvariant('114', oneID, twoID, longestCommonID) : void 0;
137
- return longestCommonID;
138
- }
139
-
140
- /**
141
- * Traverses the parent path between two IDs (either up or down). The IDs must
142
- * not be the same, and there must exist a parent path between them. If the
143
- * callback returns `false`, traversal is stopped.
144
- *
145
- * @param {?string} start ID at which to start traversal.
146
- * @param {?string} stop ID at which to end traversal.
147
- * @param {function} cb Callback to invoke each ID with.
148
- * @param {*} arg Argument to invoke the callback with.
149
- * @param {?boolean} skipFirst Whether or not to skip the first node.
150
- * @param {?boolean} skipLast Whether or not to skip the last node.
151
- * @private
152
- */
153
- function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
154
- start = start || '';
155
- stop = stop || '';
156
- !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : _prodInvariant('115', start) : void 0;
157
- var traverseUp = isAncestorIDOf(stop, start);
158
- !(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do not have a parent path.', start, stop) : _prodInvariant('116', start, stop) : void 0;
159
- // Traverse from `start` to `stop` one depth at a time.
160
- var depth = 0;
161
- var traverse = traverseUp ? getParentID : getNextDescendantID;
162
- for (var id = start;; /* until break */id = traverse(id, stop)) {
163
- var ret;
164
- if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
165
- ret = cb(id, traverseUp, arg);
166
- }
167
- if (ret === false || id === stop) {
168
- // Only break //after// visiting `stop`.
169
- break;
170
- }
171
- !(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : _prodInvariant('117', start, stop, id) : void 0;
172
- }
173
- }
174
-
175
- /**
176
- * Manages the IDs assigned to DOM representations of React components. This
177
- * uses a specific scheme in order to traverse the DOM efficiently (e.g. in
178
- * order to simulate events).
179
- *
180
- * @internal
181
- */
182
- var ReactInstanceHandles = {
183
-
184
- /**
185
- * Constructs a React root ID
186
- * @param {number} index A unique integer
187
- * @return {string} A React root ID.
188
- */
189
- createReactRootID: function (index) {
190
- return getReactRootIDString(index);
191
- },
192
-
193
- /**
194
- * Constructs a React ID by joining a root ID with a name.
195
- *
196
- * @param {string} rootID Root ID of a parent component.
197
- * @param {string} name A component's name (as flattened children).
198
- * @return {string} A React ID.
199
- * @internal
200
- */
201
- createReactID: function (rootID, name) {
202
- return rootID + name;
203
- },
204
-
205
- /**
206
- * Gets the DOM ID of the React component that is the root of the tree that
207
- * contains the React component with the supplied DOM ID.
208
- *
209
- * @param {string} id DOM ID of a React component.
210
- * @return {?string} DOM ID of the React component that is the root.
211
- * @internal
212
- */
213
- getReactRootIDFromNodeID: function (id) {
214
- if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
215
- var index = id.indexOf(SEPARATOR, 1);
216
- return index > -1 ? id.substr(0, index) : id;
217
- }
218
- return null;
219
- },
220
-
221
- /**
222
- * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
223
- * should would receive a `mouseEnter` or `mouseLeave` event.
224
- *
225
- * NOTE: Does not invoke the callback on the nearest common ancestor because
226
- * nothing "entered" or "left" that element.
227
- *
228
- * @param {string} leaveID ID being left.
229
- * @param {string} enterID ID being entered.
230
- * @param {function} cb Callback to invoke on each entered/left ID.
231
- * @param {*} upArg Argument to invoke the callback with on left IDs.
232
- * @param {*} downArg Argument to invoke the callback with on entered IDs.
233
- * @internal
234
- */
235
- traverseEnterLeave: function (leaveID, enterID, cb, upArg, downArg) {
236
- var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
237
- if (ancestorID !== leaveID) {
238
- traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
239
- }
240
- if (ancestorID !== enterID) {
241
- traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
242
- }
243
- },
244
-
245
- /**
246
- * Simulates the traversal of a two-phase, capture/bubble event dispatch.
247
- *
248
- * NOTE: This traversal happens on IDs without touching the DOM.
249
- *
250
- * @param {string} targetID ID of the target node.
251
- * @param {function} cb Callback to invoke.
252
- * @param {*} arg Argument to invoke the callback with.
253
- * @internal
254
- */
255
- traverseTwoPhase: function (targetID, cb, arg) {
256
- if (targetID) {
257
- traverseParentPath('', targetID, cb, arg, true, false);
258
- traverseParentPath(targetID, '', cb, arg, false, true);
259
- }
260
- },
261
-
262
- /**
263
- * Same as `traverseTwoPhase` but skips the `targetID`.
264
- */
265
- traverseTwoPhaseSkipTarget: function (targetID, cb, arg) {
266
- if (targetID) {
267
- traverseParentPath('', targetID, cb, arg, true, true);
268
- traverseParentPath(targetID, '', cb, arg, true, true);
269
- }
270
- },
271
-
272
- /**
273
- * Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
274
- * example, passing `.0.$row-0.1` would result in `cb` getting called
275
- * with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
276
- *
277
- * NOTE: This traversal happens on IDs without touching the DOM.
278
- *
279
- * @param {string} targetID ID of the target node.
280
- * @param {function} cb Callback to invoke.
281
- * @param {*} arg Argument to invoke the callback with.
282
- * @internal
283
- */
284
- traverseAncestors: function (targetID, cb, arg) {
285
- traverseParentPath('', targetID, cb, arg, true, false);
286
- },
287
-
288
- getFirstCommonAncestorID: getFirstCommonAncestorID,
289
-
290
- /**
291
- * Exposed for unit testing.
292
- * @private
293
- */
294
- _getNextDescendantID: getNextDescendantID,
295
-
296
- isAncestorIDOf: isAncestorIDOf,
297
-
298
- SEPARATOR: SEPARATOR
299
-
300
- };
301
-
302
- module.exports = ReactInstanceHandles;