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,36 @@
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 SyntheticEvent = require('./SyntheticEvent');
14
+
15
+ /**
16
+ * @interface Event
17
+ * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
18
+ * /#events-inputevents
19
+ */
20
+ var InputEventInterface = {
21
+ data: null
22
+ };
23
+
24
+ /**
25
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
26
+ * @param {string} dispatchMarker Marker identifying the event target.
27
+ * @param {object} nativeEvent Native browser event.
28
+ * @extends {SyntheticUIEvent}
29
+ */
30
+ function SyntheticInputEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
31
+ return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
32
+ }
33
+
34
+ SyntheticEvent.augmentClass(SyntheticInputEvent, InputEventInterface);
35
+
36
+ module.exports = SyntheticInputEvent;
@@ -0,0 +1,83 @@
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 SyntheticUIEvent = require('./SyntheticUIEvent');
14
+
15
+ var getEventCharCode = require('./getEventCharCode');
16
+ var getEventKey = require('./getEventKey');
17
+ var getEventModifierState = require('./getEventModifierState');
18
+
19
+ /**
20
+ * @interface KeyboardEvent
21
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
22
+ */
23
+ var KeyboardEventInterface = {
24
+ key: getEventKey,
25
+ location: null,
26
+ ctrlKey: null,
27
+ shiftKey: null,
28
+ altKey: null,
29
+ metaKey: null,
30
+ repeat: null,
31
+ locale: null,
32
+ getModifierState: getEventModifierState,
33
+ // Legacy Interface
34
+ charCode: function (event) {
35
+ // `charCode` is the result of a KeyPress event and represents the value of
36
+ // the actual printable character.
37
+
38
+ // KeyPress is deprecated, but its replacement is not yet final and not
39
+ // implemented in any major browser. Only KeyPress has charCode.
40
+ if (event.type === 'keypress') {
41
+ return getEventCharCode(event);
42
+ }
43
+ return 0;
44
+ },
45
+ keyCode: function (event) {
46
+ // `keyCode` is the result of a KeyDown/Up event and represents the value of
47
+ // physical keyboard key.
48
+
49
+ // The actual meaning of the value depends on the users' keyboard layout
50
+ // which cannot be detected. Assuming that it is a US keyboard layout
51
+ // provides a surprisingly accurate mapping for US and European users.
52
+ // Due to this, it is left to the user to implement at this time.
53
+ if (event.type === 'keydown' || event.type === 'keyup') {
54
+ return event.keyCode;
55
+ }
56
+ return 0;
57
+ },
58
+ which: function (event) {
59
+ // `which` is an alias for either `keyCode` or `charCode` depending on the
60
+ // type of the event.
61
+ if (event.type === 'keypress') {
62
+ return getEventCharCode(event);
63
+ }
64
+ if (event.type === 'keydown' || event.type === 'keyup') {
65
+ return event.keyCode;
66
+ }
67
+ return 0;
68
+ }
69
+ };
70
+
71
+ /**
72
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
73
+ * @param {string} dispatchMarker Marker identifying the event target.
74
+ * @param {object} nativeEvent Native browser event.
75
+ * @extends {SyntheticUIEvent}
76
+ */
77
+ function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
78
+ return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
79
+ }
80
+
81
+ SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
82
+
83
+ module.exports = SyntheticKeyboardEvent;
@@ -0,0 +1,71 @@
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 SyntheticUIEvent = require('./SyntheticUIEvent');
14
+ var ViewportMetrics = require('./ViewportMetrics');
15
+
16
+ var getEventModifierState = require('./getEventModifierState');
17
+
18
+ /**
19
+ * @interface MouseEvent
20
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
21
+ */
22
+ var MouseEventInterface = {
23
+ screenX: null,
24
+ screenY: null,
25
+ clientX: null,
26
+ clientY: null,
27
+ ctrlKey: null,
28
+ shiftKey: null,
29
+ altKey: null,
30
+ metaKey: null,
31
+ getModifierState: getEventModifierState,
32
+ button: function (event) {
33
+ // Webkit, Firefox, IE9+
34
+ // which: 1 2 3
35
+ // button: 0 1 2 (standard)
36
+ var button = event.button;
37
+ if ('which' in event) {
38
+ return button;
39
+ }
40
+ // IE<9
41
+ // which: undefined
42
+ // button: 0 0 0
43
+ // button: 1 4 2 (onmouseup)
44
+ return button === 2 ? 2 : button === 4 ? 1 : 0;
45
+ },
46
+ buttons: null,
47
+ relatedTarget: function (event) {
48
+ return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
49
+ },
50
+ // "Proprietary" Interface.
51
+ pageX: function (event) {
52
+ return 'pageX' in event ? event.pageX : event.clientX + ViewportMetrics.currentScrollLeft;
53
+ },
54
+ pageY: function (event) {
55
+ return 'pageY' in event ? event.pageY : event.clientY + ViewportMetrics.currentScrollTop;
56
+ }
57
+ };
58
+
59
+ /**
60
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
61
+ * @param {string} dispatchMarker Marker identifying the event target.
62
+ * @param {object} nativeEvent Native browser event.
63
+ * @extends {SyntheticUIEvent}
64
+ */
65
+ function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
66
+ return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
67
+ }
68
+
69
+ SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
70
+
71
+ module.exports = SyntheticMouseEvent;
@@ -0,0 +1,44 @@
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 SyntheticUIEvent = require('./SyntheticUIEvent');
14
+
15
+ var getEventModifierState = require('./getEventModifierState');
16
+
17
+ /**
18
+ * @interface TouchEvent
19
+ * @see http://www.w3.org/TR/touch-events/
20
+ */
21
+ var TouchEventInterface = {
22
+ touches: null,
23
+ targetTouches: null,
24
+ changedTouches: null,
25
+ altKey: null,
26
+ metaKey: null,
27
+ ctrlKey: null,
28
+ shiftKey: null,
29
+ getModifierState: getEventModifierState
30
+ };
31
+
32
+ /**
33
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
34
+ * @param {string} dispatchMarker Marker identifying the event target.
35
+ * @param {object} nativeEvent Native browser event.
36
+ * @extends {SyntheticUIEvent}
37
+ */
38
+ function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
39
+ return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
40
+ }
41
+
42
+ SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
43
+
44
+ module.exports = SyntheticTouchEvent;
@@ -0,0 +1,38 @@
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 SyntheticEvent = require('./SyntheticEvent');
14
+
15
+ /**
16
+ * @interface Event
17
+ * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
18
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
19
+ */
20
+ var TransitionEventInterface = {
21
+ propertyName: null,
22
+ elapsedTime: null,
23
+ pseudoElement: null
24
+ };
25
+
26
+ /**
27
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
28
+ * @param {string} dispatchMarker Marker identifying the event target.
29
+ * @param {object} nativeEvent Native browser event.
30
+ * @extends {SyntheticEvent}
31
+ */
32
+ function SyntheticTransitionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
33
+ return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
34
+ }
35
+
36
+ SyntheticEvent.augmentClass(SyntheticTransitionEvent, TransitionEventInterface);
37
+
38
+ module.exports = SyntheticTransitionEvent;
@@ -0,0 +1,58 @@
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 SyntheticEvent = require('./SyntheticEvent');
14
+
15
+ var getEventTarget = require('./getEventTarget');
16
+
17
+ /**
18
+ * @interface UIEvent
19
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
20
+ */
21
+ var UIEventInterface = {
22
+ view: function (event) {
23
+ if (event.view) {
24
+ return event.view;
25
+ }
26
+
27
+ var target = getEventTarget(event);
28
+ if (target.window === target) {
29
+ // target is a window object
30
+ return target;
31
+ }
32
+
33
+ var doc = target.ownerDocument;
34
+ // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
35
+ if (doc) {
36
+ return doc.defaultView || doc.parentWindow;
37
+ } else {
38
+ return window;
39
+ }
40
+ },
41
+ detail: function (event) {
42
+ return event.detail || 0;
43
+ }
44
+ };
45
+
46
+ /**
47
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
48
+ * @param {string} dispatchMarker Marker identifying the event target.
49
+ * @param {object} nativeEvent Native browser event.
50
+ * @extends {SyntheticEvent}
51
+ */
52
+ function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
53
+ return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
54
+ }
55
+
56
+ SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
57
+
58
+ module.exports = SyntheticUIEvent;
@@ -0,0 +1,53 @@
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 SyntheticMouseEvent = require('./SyntheticMouseEvent');
14
+
15
+ /**
16
+ * @interface WheelEvent
17
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
18
+ */
19
+ var WheelEventInterface = {
20
+ deltaX: function (event) {
21
+ return 'deltaX' in event ? event.deltaX :
22
+ // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
23
+ 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
24
+ },
25
+ deltaY: function (event) {
26
+ return 'deltaY' in event ? event.deltaY :
27
+ // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
28
+ 'wheelDeltaY' in event ? -event.wheelDeltaY :
29
+ // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
30
+ 'wheelDelta' in event ? -event.wheelDelta : 0;
31
+ },
32
+ deltaZ: null,
33
+
34
+ // Browsers without "deltaMode" is reporting in raw wheel delta where one
35
+ // notch on the scroll is always +/- 120, roughly equivalent to pixels.
36
+ // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
37
+ // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
38
+ deltaMode: null
39
+ };
40
+
41
+ /**
42
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
43
+ * @param {string} dispatchMarker Marker identifying the event target.
44
+ * @param {object} nativeEvent Native browser event.
45
+ * @extends {SyntheticMouseEvent}
46
+ */
47
+ function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
48
+ return SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
49
+ }
50
+
51
+ SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
52
+
53
+ module.exports = SyntheticWheelEvent;
@@ -0,0 +1,115 @@
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 EventPluginUtils = require('./EventPluginUtils');
15
+ var EventPropagators = require('./EventPropagators');
16
+ var SyntheticUIEvent = require('./SyntheticUIEvent');
17
+ var TouchEventUtils = require('fbjs/lib/TouchEventUtils');
18
+ var ViewportMetrics = require('./ViewportMetrics');
19
+
20
+ var isStartish = EventPluginUtils.isStartish;
21
+ var isEndish = EventPluginUtils.isEndish;
22
+
23
+ /**
24
+ * We are extending the Flow 'Touch' declaration to enable using bracket
25
+ * notation to access properties.
26
+ * Without this adjustment Flow throws
27
+ * "Indexable signature not found in Touch".
28
+ * See https://github.com/facebook/flow/issues/1323
29
+ */
30
+
31
+
32
+ /**
33
+ * Number of pixels that are tolerated in between a `touchStart` and `touchEnd`
34
+ * in order to still be considered a 'tap' event.
35
+ */
36
+ var tapMoveThreshold = 10;
37
+ var startCoords = { x: 0, y: 0 };
38
+
39
+ var Axis = {
40
+ x: { page: 'pageX', client: 'clientX', envScroll: 'currentPageScrollLeft' },
41
+ y: { page: 'pageY', client: 'clientY', envScroll: 'currentPageScrollTop' }
42
+ };
43
+
44
+ function getAxisCoordOfEvent(axis, nativeEvent) {
45
+ var singleTouch = TouchEventUtils.extractSingleTouch(nativeEvent);
46
+ if (singleTouch) {
47
+ return singleTouch[axis.page];
48
+ }
49
+ return axis.page in nativeEvent ? nativeEvent[axis.page] : nativeEvent[axis.client] + ViewportMetrics[axis.envScroll];
50
+ }
51
+
52
+ function getDistance(coords, nativeEvent) {
53
+ var pageX = getAxisCoordOfEvent(Axis.x, nativeEvent);
54
+ var pageY = getAxisCoordOfEvent(Axis.y, nativeEvent);
55
+ return Math.pow(Math.pow(pageX - coords.x, 2) + Math.pow(pageY - coords.y, 2), 0.5);
56
+ }
57
+
58
+ var touchEvents = ['topTouchStart', 'topTouchCancel', 'topTouchEnd', 'topTouchMove'];
59
+
60
+ var dependencies = ['topMouseDown', 'topMouseMove', 'topMouseUp'].concat(touchEvents);
61
+
62
+ var eventTypes = {
63
+ touchTap: {
64
+ phasedRegistrationNames: {
65
+ bubbled: 'onTouchTap',
66
+ captured: 'onTouchTapCapture'
67
+ },
68
+ dependencies: dependencies
69
+ }
70
+ };
71
+
72
+ var usedTouch = false;
73
+ var usedTouchTime = 0;
74
+ var TOUCH_DELAY = 1000;
75
+
76
+ var TapEventPlugin = {
77
+
78
+ tapMoveThreshold: tapMoveThreshold,
79
+
80
+ eventTypes: eventTypes,
81
+
82
+ extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
83
+ if (!isStartish(topLevelType) && !isEndish(topLevelType)) {
84
+ return null;
85
+ }
86
+ // on ios, there is a delay after touch event and synthetic
87
+ // mouse events, so that user can perform double tap
88
+ // solution: ignore mouse events following touchevent within small timeframe
89
+ if (touchEvents.indexOf(topLevelType) !== -1) {
90
+ usedTouch = true;
91
+ usedTouchTime = Date.now();
92
+ } else {
93
+ if (usedTouch && Date.now() - usedTouchTime < TOUCH_DELAY) {
94
+ return null;
95
+ }
96
+ }
97
+ var event = null;
98
+ var distance = getDistance(startCoords, nativeEvent);
99
+ if (isEndish(topLevelType) && distance < tapMoveThreshold) {
100
+ event = SyntheticUIEvent.getPooled(eventTypes.touchTap, targetInst, nativeEvent, nativeEventTarget);
101
+ }
102
+ if (isStartish(topLevelType)) {
103
+ startCoords.x = getAxisCoordOfEvent(Axis.x, nativeEvent);
104
+ startCoords.y = getAxisCoordOfEvent(Axis.y, nativeEvent);
105
+ } else if (isEndish(topLevelType)) {
106
+ startCoords.x = 0;
107
+ startCoords.y = 0;
108
+ }
109
+ EventPropagators.accumulateTwoPhaseDispatches(event);
110
+ return event;
111
+ }
112
+
113
+ };
114
+
115
+ module.exports = TapEventPlugin;
@@ -0,0 +1,98 @@
1
+ /**
2
+ */
3
+
4
+ 'use strict';
5
+
6
+ var TouchHistoryMath = {
7
+ /**
8
+ * This code is optimized and not intended to look beautiful. This allows
9
+ * computing of touch centroids that have moved after `touchesChangedAfter`
10
+ * timeStamp. You can compute the current centroid involving all touches
11
+ * moves after `touchesChangedAfter`, or you can compute the previous
12
+ * centroid of all touches that were moved after `touchesChangedAfter`.
13
+ *
14
+ * @param {TouchHistoryMath} touchHistory Standard Responder touch track
15
+ * data.
16
+ * @param {number} touchesChangedAfter timeStamp after which moved touches
17
+ * are considered "actively moving" - not just "active".
18
+ * @param {boolean} isXAxis Consider `x` dimension vs. `y` dimension.
19
+ * @param {boolean} ofCurrent Compute current centroid for actively moving
20
+ * touches vs. previous centroid of now actively moving touches.
21
+ * @return {number} value of centroid in specified dimension.
22
+ */
23
+ centroidDimension: function (touchHistory, touchesChangedAfter, isXAxis, ofCurrent) {
24
+ var touchBank = touchHistory.touchBank;
25
+ var total = 0;
26
+ var count = 0;
27
+
28
+ var oneTouchData = touchHistory.numberActiveTouches === 1 ? touchHistory.touchBank[touchHistory.indexOfSingleActiveTouch] : null;
29
+
30
+ if (oneTouchData !== null) {
31
+ if (oneTouchData.touchActive && oneTouchData.currentTimeStamp > touchesChangedAfter) {
32
+ total += ofCurrent && isXAxis ? oneTouchData.currentPageX : ofCurrent && !isXAxis ? oneTouchData.currentPageY : !ofCurrent && isXAxis ? oneTouchData.previousPageX : oneTouchData.previousPageY;
33
+ count = 1;
34
+ }
35
+ } else {
36
+ for (var i = 0; i < touchBank.length; i++) {
37
+ var touchTrack = touchBank[i];
38
+ if (touchTrack !== null && touchTrack !== undefined && touchTrack.touchActive && touchTrack.currentTimeStamp >= touchesChangedAfter) {
39
+ var toAdd; // Yuck, program temporarily in invalid state.
40
+ if (ofCurrent && isXAxis) {
41
+ toAdd = touchTrack.currentPageX;
42
+ } else if (ofCurrent && !isXAxis) {
43
+ toAdd = touchTrack.currentPageY;
44
+ } else if (!ofCurrent && isXAxis) {
45
+ toAdd = touchTrack.previousPageX;
46
+ } else {
47
+ toAdd = touchTrack.previousPageY;
48
+ }
49
+ total += toAdd;
50
+ count++;
51
+ }
52
+ }
53
+ }
54
+ return count > 0 ? total / count : TouchHistoryMath.noCentroid;
55
+ },
56
+
57
+ currentCentroidXOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
58
+ return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, true, // isXAxis
59
+ true // ofCurrent
60
+ );
61
+ },
62
+
63
+ currentCentroidYOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
64
+ return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, false, // isXAxis
65
+ true // ofCurrent
66
+ );
67
+ },
68
+
69
+ previousCentroidXOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
70
+ return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, true, // isXAxis
71
+ false // ofCurrent
72
+ );
73
+ },
74
+
75
+ previousCentroidYOfTouchesChangedAfter: function (touchHistory, touchesChangedAfter) {
76
+ return TouchHistoryMath.centroidDimension(touchHistory, touchesChangedAfter, false, // isXAxis
77
+ false // ofCurrent
78
+ );
79
+ },
80
+
81
+ currentCentroidX: function (touchHistory) {
82
+ return TouchHistoryMath.centroidDimension(touchHistory, 0, // touchesChangedAfter
83
+ true, // isXAxis
84
+ true // ofCurrent
85
+ );
86
+ },
87
+
88
+ currentCentroidY: function (touchHistory) {
89
+ return TouchHistoryMath.centroidDimension(touchHistory, 0, // touchesChangedAfter
90
+ false, // isXAxis
91
+ true // ofCurrent
92
+ );
93
+ },
94
+
95
+ noCentroid: -1
96
+ };
97
+
98
+ module.exports = TouchHistoryMath;