aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2011-01-17 15:45:07 -0500
committerjeresig <jeresig@gmail.com>2011-01-17 15:45:07 -0500
commit987c44bee48557f693a59bc7ecc1bbe1718c428c (patch)
tree56c29f0f3f1acf29aae301546c4397fa0c78b92f
parentac2e731b2d219fd516a166a058831de1ff949d4a (diff)
parent007e2d152e10a8feffa347b5f328d2cb4bd45327 (diff)
downloadjquery-987c44bee48557f693a59bc7ecc1bbe1718c428c.tar.gz
jquery-987c44bee48557f693a59bc7ecc1bbe1718c428c.zip
Merging pull request 183 for #7793.
-rw-r--r--src/event.js2
-rw-r--r--test/unit/event.js16
2 files changed, 13 insertions, 5 deletions
diff --git a/src/event.js b/src/event.js
index 675e5fff3..34cd91b85 100644
--- a/src/event.js
+++ b/src/event.js
@@ -603,7 +603,7 @@ jQuery.Event = function( src ) {
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
+ this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
// Event type
diff --git a/test/unit/event.js b/test/unit/event.js
index b4672a8b8..80b76505e 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -295,15 +295,15 @@ test("live/delegate immediate propagation", function() {
$p.undelegate( "click" );
});
-test("bind/delegate bubbling, isDefaultPrevented (Bug #7793)", function() {
+test("bind/delegate bubbling, isDefaultPrevented", function() {
expect(2);
var $anchor2 = jQuery( "#anchor2" ),
$main = jQuery( "#main" ),
fakeClick = function($jq) {
// Use a native click so we don't get jQuery simulated bubbling
if ( document.createEvent ) {
- var e = document.createEvent( "MouseEvents" );
- e.initEvent( "click", true, true );
+ var e = document.createEvent( 'MouseEvents' );
+ e.initEvent( "click", true, true );
$jq[0].dispatchEvent(e);
}
else if ( $jq[0].click ) {
@@ -314,7 +314,15 @@ test("bind/delegate bubbling, isDefaultPrevented (Bug #7793)", function() {
e.preventDefault();
});
$main.delegate("#foo", "click", function(e) {
- equals( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" );
+ var orig = e.originalEvent;
+
+ if ( typeof(orig.defaultPrevented) === "boolean" || typeof(orig.returnValue) === "boolean" || orig.getPreventDefault ) {
+ equals( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" );
+
+ } else {
+ // Opera < 11 doesn't implement any interface we can use, so give it a pass
+ ok( true, "isDefaultPrevented not supported by this browser, test skipped" );
+ }
});
fakeClick( $anchor2 );
$anchor2.unbind( "click" );