From d63aa0f113e9ef8ac18df147b3b7a888deb39df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Sun, 26 Oct 2014 17:14:00 -0700 Subject: [PATCH 1/3] Move Object.assign file to align with internal --- src/{vendor => }/stubs/Object.assign.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{vendor => }/stubs/Object.assign.js (100%) diff --git a/src/vendor/stubs/Object.assign.js b/src/stubs/Object.assign.js similarity index 100% rename from src/vendor/stubs/Object.assign.js rename to src/stubs/Object.assign.js From 1c241b3ebc36bd996353b5e93421128616b37c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Mon, 27 Oct 2014 16:58:54 -0700 Subject: [PATCH 2/3] Ensure PropTypes test works when warning module is replaced For example, warning might be replaced with a module that throws errors, as is the case internally when running tests. Previously we were whitelisting this test to provide time to update callsites. Now we aren't and it fails. --- src/core/__tests__/ReactPropTypes-test.js | 28 +++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/core/__tests__/ReactPropTypes-test.js b/src/core/__tests__/ReactPropTypes-test.js index 1753d6ec32c..3987e8e4fad 100644 --- a/src/core/__tests__/ReactPropTypes-test.js +++ b/src/core/__tests__/ReactPropTypes-test.js @@ -407,8 +407,32 @@ describe('ReactPropTypes', function() { }); it('should still work for deprecated typechecks', function() { - typeCheckPass(PropTypes.renderable, []); - typeCheckPass(PropTypes.renderable.isRequired, []); + // We can't use typeCheckPass here because the warning module may do + // something different in some environments. Luckily they should be fine + // if they detect that console.warn is spied upon. + spyOn(console, 'warn'); + + // typeCheckPass(PropTypes.renderable, []); + var error = PropTypes.renderable( + {testProp: []}, + 'testProp', + 'testComponent', + ReactPropTypeLocations.prop + ); + + expect(error).toBe(undefined); + expect(console.warn.calls.length).toBe(1); + + // typeCheckPass(PropTypes.renderable.isRequired, []); + error = PropTypes.renderable.isRequired( + {testProp: []}, + 'testProp', + 'testComponent', + ReactPropTypeLocations.prop + ); + + expect(error).toBe(undefined); + expect(console.warn.calls.length).toBe(1); }); }); From ff12423d639413c1934dfc2ff337b298952e99ef Mon Sep 17 00:00:00 2001 From: Tienchai Wirojsaksaree Date: Mon, 27 Oct 2014 17:02:03 -0700 Subject: [PATCH 3/3] Fixing touch/mouse issues with TapEventPlugin On ios device, browser simulates mouse events, but does that with a delay, because of double tap gesture. The problem is that TapEventPlugins listens to both types of events, so it fires twice Everytime there is a touch event, we should ignore mouse events that follow it. This way, we still respond to both mouse and touch events, just ignore the device generated ones. --- src/browser/eventPlugins/TapEventPlugin.js | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/browser/eventPlugins/TapEventPlugin.js b/src/browser/eventPlugins/TapEventPlugin.js index a44bcf835e2..8fa3e169882 100644 --- a/src/browser/eventPlugins/TapEventPlugin.js +++ b/src/browser/eventPlugins/TapEventPlugin.js @@ -62,13 +62,15 @@ var dependencies = [ topLevelTypes.topMouseUp ]; +var touchDependencies = [ + topLevelTypes.topTouchStart, + topLevelTypes.topTouchCancel, + topLevelTypes.topTouchEnd, + topLevelTypes.topTouchMove +]; + if (EventPluginUtils.useTouchEvents) { - dependencies.push( - topLevelTypes.topTouchCancel, - topLevelTypes.topTouchEnd, - topLevelTypes.topTouchStart, - topLevelTypes.topTouchMove - ); + dependencies = dependencies.concat(touchDependencies); } var eventTypes = { @@ -81,6 +83,10 @@ var eventTypes = { } }; +var usedTouch = false; +var usedTouchTime = 0; +var TOUCH_DELAY = 500; + var TapEventPlugin = { tapMoveThreshold: tapMoveThreshold, @@ -103,6 +109,17 @@ var TapEventPlugin = { if (!isStartish(topLevelType) && !isEndish(topLevelType)) { return null; } + // on ios, there is a delay after touch event and synthetic + // mouse events, so that user can perform double tap + // solution: ignore mouse events following touchevent within small timeframe + if (touchDependencies.indexOf(topLevelType) !== -1) { + usedTouch = true; + usedTouchTime = Date.now(); + } else { + if (usedTouch && (Date.now() - usedTouchTime < TOUCH_DELAY)) { + return; + } + } var event = null; var distance = getDistance(startCoords, nativeEvent); if (isEndish(topLevelType) && distance < tapMoveThreshold) {