diff options
| author | Vojta Jina | 2011-08-30 13:14:55 +0200 |
|---|---|---|
| committer | Vojta Jina | 2011-09-08 23:00:59 +0200 |
| commit | 66dec7755573a1c07a1fe8e0dd9bc5fc51dbaac9 (patch) | |
| tree | dcdefd40fc34251dbc704808ce20396b1453b371 /src/scenario/dsl.js | |
| parent | 8fa79066e2cea470086769aa59e7cc9d3aa30d81 (diff) | |
| download | angular.js-66dec7755573a1c07a1fe8e0dd9bc5fc51dbaac9.tar.bz2 | |
fix(scenario): do not navigate if click event was cancelled
This is jQuery incompatible hack.
But we were doing monkey patching there anyway...
`$(...).trigger('click')` returns an array of return values, so that scenario
runner knows, whether the event default action was cancelled.
Without this fix, scenario runner was doing navigation even if JS code called
`event.preventDefault()`.
Note, this does not work in FF6
Diffstat (limited to 'src/scenario/dsl.js')
| -rw-r--r-- | src/scenario/dsl.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/scenario/dsl.js b/src/scenario/dsl.js index 2190f7f7..946f56d3 100644 --- a/src/scenario/dsl.js +++ b/src/scenario/dsl.js @@ -323,8 +323,9 @@ angular.scenario.dsl('element', function() { return this.addFutureAction("element '" + this.label + "' click", function($window, $document, done) { var elements = $document.elements(); var href = elements.attr('href'); - elements.trigger('click'); - if (href && elements[0].nodeName.toUpperCase() === 'A') { + var eventProcessDefault = elements.trigger('click')[0]; + + if (href && elements[0].nodeName.toUpperCase() === 'A' && eventProcessDefault) { this.application.navigateTo(href, function() { done(); }, done); |
