Skip to content

Commit 2dc0275

Browse files
committed
fix(Tests): Allow touch event simulation
jquery.simulate.js doesn't, by default, allow for touch events. A couple simple changes add that
1 parent 4d7a384 commit 2dc0275

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: lib/test/jquery.simulate.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
;(function( $, undefined ) {
1313

1414
var rkeyEvent = /^key/,
15-
rmouseEvent = /^(?:mouse|contextmenu)|click/;
15+
rmouseEvent = /^(?:mouse|contextmenu)|click/,
16+
rtouchEvent = /^touch/;
1617

1718
$.fn.simulate = function( type, options ) {
1819
return this.each(function() {
@@ -82,13 +83,16 @@ $.extend( $.simulate.prototype, {
8283
if ( rmouseEvent.test( type ) ) {
8384
return this.mouseEvent( type, options );
8485
}
86+
else if ( rtouchEvent.test( type) ) {
87+
return this.mouseEvent( type, options );
88+
}
8589
},
8690

8791
mouseEvent: function( type, options ) {
8892
var event, eventDoc, doc, body;
8993
options = $.extend({
9094
bubbles: true,
91-
cancelable: (type !== "mousemove"),
95+
cancelable: (type !== "mousemove" && type !== "touchmove"),
9296
view: window,
9397
detail: 0,
9498
screenX: 0,

0 commit comments

Comments
 (0)