Skip to content

Commit

Permalink
fix(Tests): Allow touch event simulation
Browse files Browse the repository at this point in the history
jquery.simulate.js doesn't, by default, allow for touch events. A couple
simple changes add that
  • Loading branch information
c0bra committed Dec 10, 2014
1 parent 4d7a384 commit 2dc0275
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/test/jquery.simulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
;(function( $, undefined ) {

var rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/;
rmouseEvent = /^(?:mouse|contextmenu)|click/,
rtouchEvent = /^touch/;

$.fn.simulate = function( type, options ) {
return this.each(function() {
Expand Down Expand Up @@ -82,13 +83,16 @@ $.extend( $.simulate.prototype, {
if ( rmouseEvent.test( type ) ) {
return this.mouseEvent( type, options );
}
else if ( rtouchEvent.test( type) ) {
return this.mouseEvent( type, options );
}
},

mouseEvent: function( type, options ) {
var event, eventDoc, doc, body;
options = $.extend({
bubbles: true,
cancelable: (type !== "mousemove"),
cancelable: (type !== "mousemove" && type !== "touchmove"),
view: window,
detail: 0,
screenX: 0,
Expand Down

0 comments on commit 2dc0275

Please sign in to comment.