Commit 39b5e4ce 39b5e4ced3369946c0066c99ff3b6cafc86601dd by Nicolas Perriault

fixes #153 - erroneous mouse event results when event.preventDefault() was used

1 parent 59bbf5de
......@@ -5,6 +5,7 @@ XXXX-XX-XX, v1.0.0
------------------
- fixed [#164](https://github.com/n1k0/casperjs/issues/164) - ability to force CLI parameters as strings (see [related documentation](http://casperjs.org/cli.html#raw)).
- fixed [#153](https://github.com/n1k0/casperjs/issues/153) - erroneous mouse event results when event.preventDefault() was used
2012-06-26, v1.0.0-RC1
----------------------
......
Subproject commit 03a0fac7329753f0b25bfe10d517fb214de479d0
Subproject commit f2d604f78f2c6005c6fd6b63617a2df67c48bab3
......
......@@ -407,11 +407,20 @@
this.log("mouseEvent(): Couldn't find any element matching '" + selector + "' selector", "error");
return false;
}
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent(type, true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, elem);
// dispatchEvent return value is false if at least one of the event
// handlers which handled this event called preventDefault
return elem.dispatchEvent(evt);
try {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent(type, true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, elem);
// dispatchEvent return value is false if at least one of the event
// handlers which handled this event called preventDefault;
// so we cannot returns this results as it cannot accurately informs on the status
// of the operation
// let's assume the event has been sent ok it didn't raise any error
elem.dispatchEvent(evt);
return true;
} catch (e) {
this.log("Failed dispatching " + type + "mouse event on " + selector + ": " + e, "error");
return false;
}
};
/**
......