@samitouri / QOS-React-2 / commits / 9c4c2f58ea

Kill React.initializeTouchEvents for good

Now that #1169 is fixed, the only thing this is used for is to determine whether `onTouchTap` causes touch listeners to be added. The only internal uses of TapEventPlugin are where touch events are already initialized (so this doesn't make a difference) and we don't support `onTouchTap` as part of the public API so this should be safe.

Ben Alpert committed Mar 17, 2015 at 13:48 UTC 9c4c2f58ea103f84c055d2241c0f178c79d90fd9
8 files changed +8 -35
docs/docs/03-interactivity-and-dynamic-uis.md
-2
@@ -40,8 +40,6 @@ React.render(
40
41 With React you simply pass your event handler as a camelCased prop similar to how you'd do it in normal HTML. React ensures that all events behave identically in IE8 and above by implementing a synthetic event system. That is, React knows how to bubble and capture events according to the spec, and the events passed to your event handler are guaranteed to be consistent with [the W3C spec](http://www.w3.org/TR/DOM-Level-3-Events/), regardless of which browser you're using.
42
43 -If you'd like to use React on a touch device such as a phone or tablet, simply call `React.initializeTouchEvents(true);` to enable touch event handling.
44 -
43
44 ## Under the Hood: Autobinding and Event Delegation
45
docs/docs/03-interactivity-and-dynamic-uis.zh-CN.md
-2
@@ -40,8 +40,6 @@ React.render(
40
41 React 里只需把事件处理器(event handler)以骆峰命名(camelCased)形式当作组件的 props 传入即可,就像使用普通 HTML 那样。React 内部创建一套合成事件系统来使所有事件在 IE8 和以上浏览器表现一致。也就是说,React 知道如何冒泡和捕获事件,而且你的事件处理器接收到的 events 参数与 [W3C 规范](http://www.w3.org/TR/DOM-Level-3-Events/) 一致,无论你使用哪种浏览器。
42
43 -如果需要在手机或平板等触摸设备上使用 React,需要调用 `React.initializeTouchEvents(true);` 启用触摸事件处理。
44 -
43 ## 幕后原理:自动绑定(Autobinding)和事件代理(Event Delegation)
44
45 在幕后,React 做了一些操作来让代码高效运行且易于理解。
docs/docs/ref-01-top-level-api.md
-9
@@ -150,15 +150,6 @@ If this component has been mounted into the DOM, this returns the corresponding
150 `React.PropTypes` includes types that can be used with a component's `propTypes` object to validate props being passed to your components. For more information about `propTypes`, see [Reusable Components](/react/docs/reusable-components.html).
151
152
153 -### React.initializeTouchEvents
154 -
155 -```javascript
156 -initializeTouchEvents(boolean shouldUseTouch)
157 -```
158 -
159 -Configure React's event system to handle touch events on mobile devices.
160 -
161 -
153 ### React.Children
154
155 `React.Children` provides utilities for dealing with the `this.props.children` opaque data structure.
docs/docs/ref-05-events.md
-3
@@ -141,9 +141,6 @@ boolean shiftKey
141
142 ### Touch events
143
144 -To enable touch events, call `React.initializeTouchEvents(true)` before
145 -rendering any component.
146 -
144 Event names:
145
146 ```
docs/docs/ref-05-events.zh-CN.md
-2
@@ -138,8 +138,6 @@ boolean shiftKey
138
139 ### 触控事件
140
141 -在渲染任意组件之前调用 `React.initializeTouchEvents(true)`,以启用触控事件。
142 -
141 事件名称:
142
143 ```
src/browser/eventPlugins/TapEventPlugin.js
+7 -11
@@ -56,22 +56,18 @@ function getDistance(coords, nativeEvent) {
56 );
57 }
58
59 -var dependencies = [
60 - topLevelTypes.topMouseDown,
61 - topLevelTypes.topMouseMove,
62 - topLevelTypes.topMouseUp
63 -];
64 -
65 -var touchDependencies = [
59 +var touchEvents = [
60 topLevelTypes.topTouchStart,
61 topLevelTypes.topTouchCancel,
62 topLevelTypes.topTouchEnd,
63 topLevelTypes.topTouchMove
64 ];
65
72 -if (EventPluginUtils.useTouchEvents) {
73 - dependencies = dependencies.concat(touchDependencies);
74 -}
66 +var dependencies = [
67 + topLevelTypes.topMouseDown,
68 + topLevelTypes.topMouseMove,
69 + topLevelTypes.topMouseUp
70 +].concat(touchEvents);
71
72 var eventTypes = {
73 touchTap: {
@@ -112,7 +108,7 @@ var TapEventPlugin = {
108 // on ios, there is a delay after touch event and synthetic
109 // mouse events, so that user can perform double tap
110 // solution: ignore mouse events following touchevent within small timeframe
115 - if (touchDependencies.indexOf(topLevelType) !== -1) {
111 + if (touchEvents.indexOf(topLevelType) !== -1) {
112 usedTouch = true;
113 usedTouchTime = Date.now();
114 } else {
src/browser/ui/React.js
-4
@@ -13,7 +13,6 @@
13
14 'use strict';
15
16 -var EventPluginUtils = require('EventPluginUtils');
16 var ReactChildren = require('ReactChildren');
17 var ReactComponent = require('ReactComponent');
18 var ReactClass = require('ReactClass');
@@ -60,9 +59,6 @@ var React = {
59 Component: ReactComponent,
60 DOM: ReactDOM,
61 PropTypes: ReactPropTypes,
63 - initializeTouchEvents: function(shouldUseTouch) {
64 - EventPluginUtils.useTouchEvents = shouldUseTouch;
65 - },
62 createClass: ReactClass.createClass,
63 createElement: createElement,
64 cloneElement: cloneElement,
src/event/EventPluginUtils.js
+1 -2
@@ -211,8 +211,7 @@ var EventPluginUtils = {
211 executeDispatchesInOrder: executeDispatchesInOrder,
212 executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
213 hasDispatches: hasDispatches,
214 - injection: injection,
215 - useTouchEvents: false
214 + injection: injection
215 };
216
217 module.exports = EventPluginUtils;