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,236 @@
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 DOMProperty = require('./DOMProperty');
14
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
15
+ var ReactInstrumentation = require('./ReactInstrumentation');
16
+
17
+ var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser');
18
+ var warning = require('fbjs/lib/warning');
19
+
20
+ var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
21
+ var illegalAttributeNameCache = {};
22
+ var validatedAttributeNameCache = {};
23
+
24
+ function isAttributeNameSafe(attributeName) {
25
+ if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
26
+ return true;
27
+ }
28
+ if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
29
+ return false;
30
+ }
31
+ if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
32
+ validatedAttributeNameCache[attributeName] = true;
33
+ return true;
34
+ }
35
+ illegalAttributeNameCache[attributeName] = true;
36
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : void 0;
37
+ return false;
38
+ }
39
+
40
+ function shouldIgnoreValue(propertyInfo, value) {
41
+ return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
42
+ }
43
+
44
+ /**
45
+ * Operations for dealing with DOM properties.
46
+ */
47
+ var DOMPropertyOperations = {
48
+
49
+ /**
50
+ * Creates markup for the ID property.
51
+ *
52
+ * @param {string} id Unescaped ID.
53
+ * @return {string} Markup string.
54
+ */
55
+ createMarkupForID: function (id) {
56
+ return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
57
+ },
58
+
59
+ setAttributeForID: function (node, id) {
60
+ node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
61
+ },
62
+
63
+ createMarkupForRoot: function () {
64
+ return DOMProperty.ROOT_ATTRIBUTE_NAME + '=""';
65
+ },
66
+
67
+ setAttributeForRoot: function (node) {
68
+ node.setAttribute(DOMProperty.ROOT_ATTRIBUTE_NAME, '');
69
+ },
70
+
71
+ /**
72
+ * Creates markup for a property.
73
+ *
74
+ * @param {string} name
75
+ * @param {*} value
76
+ * @return {?string} Markup string, or null if the property was invalid.
77
+ */
78
+ createMarkupForProperty: function (name, value) {
79
+ var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
80
+ if (propertyInfo) {
81
+ if (shouldIgnoreValue(propertyInfo, value)) {
82
+ return '';
83
+ }
84
+ var attributeName = propertyInfo.attributeName;
85
+ if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
86
+ return attributeName + '=""';
87
+ }
88
+ return attributeName + '=' + quoteAttributeValueForBrowser(value);
89
+ } else if (DOMProperty.isCustomAttribute(name)) {
90
+ if (value == null) {
91
+ return '';
92
+ }
93
+ return name + '=' + quoteAttributeValueForBrowser(value);
94
+ }
95
+ return null;
96
+ },
97
+
98
+ /**
99
+ * Creates markup for a custom property.
100
+ *
101
+ * @param {string} name
102
+ * @param {*} value
103
+ * @return {string} Markup string, or empty string if the property was invalid.
104
+ */
105
+ createMarkupForCustomAttribute: function (name, value) {
106
+ if (!isAttributeNameSafe(name) || value == null) {
107
+ return '';
108
+ }
109
+ return name + '=' + quoteAttributeValueForBrowser(value);
110
+ },
111
+
112
+ /**
113
+ * Sets the value for a property on a node.
114
+ *
115
+ * @param {DOMElement} node
116
+ * @param {string} name
117
+ * @param {*} value
118
+ */
119
+ setValueForProperty: function (node, name, value) {
120
+ var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
121
+ if (propertyInfo) {
122
+ var mutationMethod = propertyInfo.mutationMethod;
123
+ if (mutationMethod) {
124
+ mutationMethod(node, value);
125
+ } else if (shouldIgnoreValue(propertyInfo, value)) {
126
+ this.deleteValueForProperty(node, name);
127
+ return;
128
+ } else if (propertyInfo.mustUseProperty) {
129
+ // Contrary to `setAttribute`, object properties are properly
130
+ // `toString`ed by IE8/9.
131
+ node[propertyInfo.propertyName] = value;
132
+ } else {
133
+ var attributeName = propertyInfo.attributeName;
134
+ var namespace = propertyInfo.attributeNamespace;
135
+ // `setAttribute` with objects becomes only `[object]` in IE8/9,
136
+ // ('' + value) makes it output the correct toString()-value.
137
+ if (namespace) {
138
+ node.setAttributeNS(namespace, attributeName, '' + value);
139
+ } else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
140
+ node.setAttribute(attributeName, '');
141
+ } else {
142
+ node.setAttribute(attributeName, '' + value);
143
+ }
144
+ }
145
+ } else if (DOMProperty.isCustomAttribute(name)) {
146
+ DOMPropertyOperations.setValueForAttribute(node, name, value);
147
+ return;
148
+ }
149
+
150
+ if (process.env.NODE_ENV !== 'production') {
151
+ var payload = {};
152
+ payload[name] = value;
153
+ ReactInstrumentation.debugTool.onHostOperation({
154
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
155
+ type: 'update attribute',
156
+ payload: payload
157
+ });
158
+ }
159
+ },
160
+
161
+ setValueForAttribute: function (node, name, value) {
162
+ if (!isAttributeNameSafe(name)) {
163
+ return;
164
+ }
165
+ if (value == null) {
166
+ node.removeAttribute(name);
167
+ } else {
168
+ node.setAttribute(name, '' + value);
169
+ }
170
+
171
+ if (process.env.NODE_ENV !== 'production') {
172
+ var payload = {};
173
+ payload[name] = value;
174
+ ReactInstrumentation.debugTool.onHostOperation({
175
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
176
+ type: 'update attribute',
177
+ payload: payload
178
+ });
179
+ }
180
+ },
181
+
182
+ /**
183
+ * Deletes an attributes from a node.
184
+ *
185
+ * @param {DOMElement} node
186
+ * @param {string} name
187
+ */
188
+ deleteValueForAttribute: function (node, name) {
189
+ node.removeAttribute(name);
190
+ if (process.env.NODE_ENV !== 'production') {
191
+ ReactInstrumentation.debugTool.onHostOperation({
192
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
193
+ type: 'remove attribute',
194
+ payload: name
195
+ });
196
+ }
197
+ },
198
+
199
+ /**
200
+ * Deletes the value for a property on a node.
201
+ *
202
+ * @param {DOMElement} node
203
+ * @param {string} name
204
+ */
205
+ deleteValueForProperty: function (node, name) {
206
+ var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
207
+ if (propertyInfo) {
208
+ var mutationMethod = propertyInfo.mutationMethod;
209
+ if (mutationMethod) {
210
+ mutationMethod(node, undefined);
211
+ } else if (propertyInfo.mustUseProperty) {
212
+ var propName = propertyInfo.propertyName;
213
+ if (propertyInfo.hasBooleanValue) {
214
+ node[propName] = false;
215
+ } else {
216
+ node[propName] = '';
217
+ }
218
+ } else {
219
+ node.removeAttribute(propertyInfo.attributeName);
220
+ }
221
+ } else if (DOMProperty.isCustomAttribute(name)) {
222
+ node.removeAttribute(name);
223
+ }
224
+
225
+ if (process.env.NODE_ENV !== 'production') {
226
+ ReactInstrumentation.debugTool.onHostOperation({
227
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
228
+ type: 'remove attribute',
229
+ payload: name
230
+ });
231
+ }
232
+ }
233
+
234
+ };
235
+
236
+ module.exports = DOMPropertyOperations;
@@ -0,0 +1,47 @@
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 _prodInvariant = require('./reactProdInvariant');
14
+
15
+ var DOMLazyTree = require('./DOMLazyTree');
16
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
17
+
18
+ var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup');
19
+ var emptyFunction = require('fbjs/lib/emptyFunction');
20
+ var invariant = require('fbjs/lib/invariant');
21
+
22
+ var Danger = {
23
+
24
+ /**
25
+ * Replaces a node with a string of markup at its current position within its
26
+ * parent. The markup must render into a single root node.
27
+ *
28
+ * @param {DOMElement} oldChild Child node to replace.
29
+ * @param {string} markup Markup to render in place of the child node.
30
+ * @internal
31
+ */
32
+ dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
33
+ !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a worker thread. Make sure `window` and `document` are available globally before requiring React when unit testing or use ReactDOMServer.renderToString() for server rendering.') : _prodInvariant('56') : void 0;
34
+ !markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : _prodInvariant('57') : void 0;
35
+ !(oldChild.nodeName !== 'HTML') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the <html> node. This is because browser quirks make this unreliable and/or slow. If you want to render to the root you must use server rendering. See ReactDOMServer.renderToString().') : _prodInvariant('58') : void 0;
36
+
37
+ if (typeof markup === 'string') {
38
+ var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
39
+ oldChild.parentNode.replaceChild(newChild, oldChild);
40
+ } else {
41
+ DOMLazyTree.replaceChildWithTree(oldChild, markup);
42
+ }
43
+ }
44
+
45
+ };
46
+
47
+ module.exports = Danger;
@@ -0,0 +1,25 @@
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
+ /**
14
+ * Module that is injectable into `EventPluginHub`, that specifies a
15
+ * deterministic ordering of `EventPlugin`s. A convenient way to reason about
16
+ * plugins, without having to package every one of them. This is better than
17
+ * having plugins be ordered in the same order that they are injected because
18
+ * that ordering would be influenced by the packaging order.
19
+ * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
20
+ * preventing default on events is convenient in `SimpleEventPlugin` handlers.
21
+ */
22
+
23
+ var DefaultEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
24
+
25
+ module.exports = DefaultEventPluginOrder;
@@ -0,0 +1,99 @@
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 EventPropagators = require('./EventPropagators');
14
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
15
+ var SyntheticMouseEvent = require('./SyntheticMouseEvent');
16
+
17
+ var eventTypes = {
18
+ mouseEnter: {
19
+ registrationName: 'onMouseEnter',
20
+ dependencies: ['topMouseOut', 'topMouseOver']
21
+ },
22
+ mouseLeave: {
23
+ registrationName: 'onMouseLeave',
24
+ dependencies: ['topMouseOut', 'topMouseOver']
25
+ }
26
+ };
27
+
28
+ var EnterLeaveEventPlugin = {
29
+
30
+ eventTypes: eventTypes,
31
+
32
+ /**
33
+ * For almost every interaction we care about, there will be both a top-level
34
+ * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
35
+ * we do not extract duplicate events. However, moving the mouse into the
36
+ * browser from outside will not fire a `mouseout` event. In this case, we use
37
+ * the `mouseover` top-level event.
38
+ */
39
+ extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
40
+ if (topLevelType === 'topMouseOver' && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
41
+ return null;
42
+ }
43
+ if (topLevelType !== 'topMouseOut' && topLevelType !== 'topMouseOver') {
44
+ // Must not be a mouse in or mouse out - ignoring.
45
+ return null;
46
+ }
47
+
48
+ var win;
49
+ if (nativeEventTarget.window === nativeEventTarget) {
50
+ // `nativeEventTarget` is probably a window object.
51
+ win = nativeEventTarget;
52
+ } else {
53
+ // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
54
+ var doc = nativeEventTarget.ownerDocument;
55
+ if (doc) {
56
+ win = doc.defaultView || doc.parentWindow;
57
+ } else {
58
+ win = window;
59
+ }
60
+ }
61
+
62
+ var from;
63
+ var to;
64
+ if (topLevelType === 'topMouseOut') {
65
+ from = targetInst;
66
+ var related = nativeEvent.relatedTarget || nativeEvent.toElement;
67
+ to = related ? ReactDOMComponentTree.getClosestInstanceFromNode(related) : null;
68
+ } else {
69
+ // Moving to a node from outside the window.
70
+ from = null;
71
+ to = targetInst;
72
+ }
73
+
74
+ if (from === to) {
75
+ // Nothing pertains to our managed components.
76
+ return null;
77
+ }
78
+
79
+ var fromNode = from == null ? win : ReactDOMComponentTree.getNodeFromInstance(from);
80
+ var toNode = to == null ? win : ReactDOMComponentTree.getNodeFromInstance(to);
81
+
82
+ var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, from, nativeEvent, nativeEventTarget);
83
+ leave.type = 'mouseleave';
84
+ leave.target = fromNode;
85
+ leave.relatedTarget = toNode;
86
+
87
+ var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, to, nativeEvent, nativeEventTarget);
88
+ enter.type = 'mouseenter';
89
+ enter.target = toNode;
90
+ enter.relatedTarget = fromNode;
91
+
92
+ EventPropagators.accumulateEnterLeaveDispatches(leave, enter, from, to);
93
+
94
+ return [leave, enter];
95
+ }
96
+
97
+ };
98
+
99
+ module.exports = EnterLeaveEventPlugin;
@@ -0,0 +1,91 @@
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
+ /**
14
+ * Types of raw signals from the browser caught at the top level.
15
+ */
16
+ var topLevelTypes = {
17
+ topAbort: null,
18
+ topAnimationEnd: null,
19
+ topAnimationIteration: null,
20
+ topAnimationStart: null,
21
+ topBlur: null,
22
+ topCanPlay: null,
23
+ topCanPlayThrough: null,
24
+ topChange: null,
25
+ topClick: null,
26
+ topCompositionEnd: null,
27
+ topCompositionStart: null,
28
+ topCompositionUpdate: null,
29
+ topContextMenu: null,
30
+ topCopy: null,
31
+ topCut: null,
32
+ topDoubleClick: null,
33
+ topDrag: null,
34
+ topDragEnd: null,
35
+ topDragEnter: null,
36
+ topDragExit: null,
37
+ topDragLeave: null,
38
+ topDragOver: null,
39
+ topDragStart: null,
40
+ topDrop: null,
41
+ topDurationChange: null,
42
+ topEmptied: null,
43
+ topEncrypted: null,
44
+ topEnded: null,
45
+ topError: null,
46
+ topFocus: null,
47
+ topInput: null,
48
+ topInvalid: null,
49
+ topKeyDown: null,
50
+ topKeyPress: null,
51
+ topKeyUp: null,
52
+ topLoad: null,
53
+ topLoadedData: null,
54
+ topLoadedMetadata: null,
55
+ topLoadStart: null,
56
+ topMouseDown: null,
57
+ topMouseMove: null,
58
+ topMouseOut: null,
59
+ topMouseOver: null,
60
+ topMouseUp: null,
61
+ topPaste: null,
62
+ topPause: null,
63
+ topPlay: null,
64
+ topPlaying: null,
65
+ topProgress: null,
66
+ topRateChange: null,
67
+ topReset: null,
68
+ topScroll: null,
69
+ topSeeked: null,
70
+ topSeeking: null,
71
+ topSelectionChange: null,
72
+ topStalled: null,
73
+ topSubmit: null,
74
+ topSuspend: null,
75
+ topTextInput: null,
76
+ topTimeUpdate: null,
77
+ topTouchCancel: null,
78
+ topTouchEnd: null,
79
+ topTouchMove: null,
80
+ topTouchStart: null,
81
+ topTransitionEnd: null,
82
+ topVolumeChange: null,
83
+ topWaiting: null,
84
+ topWheel: null
85
+ };
86
+
87
+ var EventConstants = {
88
+ topLevelTypes: topLevelTypes
89
+ };
90
+
91
+ module.exports = EventConstants;