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 ...@@ -5,6 +5,7 @@ XXXX-XX-XX, v1.0.0
5 ------------------ 5 ------------------
6 6
7 - 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)). 7 - 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)).
8 - fixed [#153](https://github.com/n1k0/casperjs/issues/153) - erroneous mouse event results when event.preventDefault() was used
8 9
9 2012-06-26, v1.0.0-RC1 10 2012-06-26, v1.0.0-RC1
10 ---------------------- 11 ----------------------
......
1 Subproject commit 03a0fac7329753f0b25bfe10d517fb214de479d0 1 Subproject commit f2d604f78f2c6005c6fd6b63617a2df67c48bab3
......
...@@ -407,11 +407,20 @@ ...@@ -407,11 +407,20 @@
407 this.log("mouseEvent(): Couldn't find any element matching '" + selector + "' selector", "error"); 407 this.log("mouseEvent(): Couldn't find any element matching '" + selector + "' selector", "error");
408 return false; 408 return false;
409 } 409 }
410 var evt = document.createEvent("MouseEvents"); 410 try {
411 evt.initMouseEvent(type, true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, elem); 411 var evt = document.createEvent("MouseEvents");
412 // dispatchEvent return value is false if at least one of the event 412 evt.initMouseEvent(type, true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, elem);
413 // handlers which handled this event called preventDefault 413 // dispatchEvent return value is false if at least one of the event
414 return elem.dispatchEvent(evt); 414 // handlers which handled this event called preventDefault;
415 // so we cannot returns this results as it cannot accurately informs on the status
416 // of the operation
417 // let's assume the event has been sent ok it didn't raise any error
418 elem.dispatchEvent(evt);
419 return true;
420 } catch (e) {
421 this.log("Failed dispatching " + type + "mouse event on " + selector + ": " + e, "error");
422 return false;
423 }
415 }; 424 };
416 425
417 /** 426 /**
......