Merging pull request 183 for #7793.
This commit is contained in:
commit
987c44bee4
|
@ -295,14 +295,14 @@ test("live/delegate immediate propagation", function() {
|
||||||
$p.undelegate( "click" );
|
$p.undelegate( "click" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("bind/delegate bubbling, isDefaultPrevented (Bug #7793)", function() {
|
test("bind/delegate bubbling, isDefaultPrevented", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
var $anchor2 = jQuery( "#anchor2" ),
|
var $anchor2 = jQuery( "#anchor2" ),
|
||||||
$main = jQuery( "#main" ),
|
$main = jQuery( "#main" ),
|
||||||
fakeClick = function($jq) {
|
fakeClick = function($jq) {
|
||||||
// Use a native click so we don't get jQuery simulated bubbling
|
// Use a native click so we don't get jQuery simulated bubbling
|
||||||
if ( document.createEvent ) {
|
if ( document.createEvent ) {
|
||||||
var e = document.createEvent( "MouseEvents" );
|
var e = document.createEvent( 'MouseEvents' );
|
||||||
e.initEvent( "click", true, true );
|
e.initEvent( "click", true, true );
|
||||||
$jq[0].dispatchEvent(e);
|
$jq[0].dispatchEvent(e);
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,15 @@ test("bind/delegate bubbling, isDefaultPrevented (Bug #7793)", function() {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$main.delegate("#foo", "click", function(e) {
|
$main.delegate("#foo", "click", function(e) {
|
||||||
|
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" );
|
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 );
|
fakeClick( $anchor2 );
|
||||||
$anchor2.unbind( "click" );
|
$anchor2.unbind( "click" );
|
||||||
|
|
Loading…
Reference in a new issue