Skip to content

Commit

Permalink
fixes #153 - erroneous mouse event results when event.preventDefault(…
Browse files Browse the repository at this point in the history
…) was used
  • Loading branch information
n1k0 committed Jul 8, 2012
1 parent 59bbf5d commit 39b5e4c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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
----------------------
Expand Down
2 changes: 1 addition & 1 deletion docs
Submodule docs updated from 03a0fa to f2d604
19 changes: 14 additions & 5 deletions modules/clientutils.js
Expand Up @@ -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;
}
};

/**
Expand Down

0 comments on commit 39b5e4c

Please sign in to comment.