Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 7a87394

Browse files
committed
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).
1 parent 65bed61 commit 7a87394

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: src/ngScenario/browserTrigger.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,15 @@
134134
}
135135

136136
function createTouchEvent(element, eventType, x, y) {
137-
var evnt = document.createEvent('TouchEvent');
137+
var evnt = new Event(eventType);
138138
x = x || 0;
139139
y = y || 0;
140140

141141
var touch = document.createTouch(window, element, Date.now(), x, y, x, y);
142142
var touches = document.createTouchList(touch);
143-
var targetTouches = document.createTouchList(touch);
144-
var changedTouches = document.createTouchList(touch);
145143

146-
evnt.initTouchEvent(eventType, true, true, window, null, 0, 0, 0, 0, false, false, false, false,
147-
touches, targetTouches, changedTouches, 1, 0);
144+
evnt.touches = touches;
145+
148146
return evnt;
149147
}
150148
}());

0 commit comments

Comments
 (0)