From 7a87394747b2c45a8580b930a0b4809eae2b35aa Mon Sep 17 00:00:00 2001 From: Georgios Kalpakas Date: Thu, 2 Apr 2015 19:16:21 +0300 Subject: [PATCH] fix(ntTouch): make tests pass on Chrome with touch enabled Using the `initTouchEvent()` method (introduces in 06a9f0a) did not correctly initialize the event, nor did the event get dispatched on the target element (e.g. on desktop Chrome with touch-events enabled). Using the `Event` constructor and manually attaching a `TouchList`, works around the issue (although not a proper fix). --- src/ngScenario/browserTrigger.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ngScenario/browserTrigger.js b/src/ngScenario/browserTrigger.js index bcbdb27acc29..f3c22fe5ff62 100644 --- a/src/ngScenario/browserTrigger.js +++ b/src/ngScenario/browserTrigger.js @@ -134,17 +134,15 @@ } function createTouchEvent(element, eventType, x, y) { - var evnt = document.createEvent('TouchEvent'); + var evnt = new Event(eventType); x = x || 0; y = y || 0; var touch = document.createTouch(window, element, Date.now(), x, y, x, y); var touches = document.createTouchList(touch); - var targetTouches = document.createTouchList(touch); - var changedTouches = document.createTouchList(touch); - evnt.initTouchEvent(eventType, true, true, window, null, 0, 0, 0, 0, false, false, false, false, - touches, targetTouches, changedTouches, 1, 0); + evnt.touches = touches; + return evnt; } }());