Event: Don't test stopImmediatePropagation in Android 2.3

Android 2.3 doesn't support stopImmediatePropagation; jQuery fallbacks
to stopPropagation in such a case.
This commit is contained in:
Michał Gołębiowski 2014-03-18 20:55:50 +01:00
parent b5074944b0
commit 14e0a632a0

View File

@ -387,7 +387,13 @@ test("on immediate propagation", function() {
}); });
test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() { test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
expect( 3 ); // Support: Android 2.3
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
expect( 2 );
} else {
expect( 3 );
}
var $anchor2 = jQuery( "#anchor2" ), var $anchor2 = jQuery( "#anchor2" ),
$main = jQuery( "#qunit-fixture" ), $main = jQuery( "#qunit-fixture" ),
neverCallMe = function() { neverCallMe = function() {
@ -418,13 +424,18 @@ test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
$anchor2.off( "click" ); $anchor2.off( "click" );
$main.off( "click", "**" ); $main.off( "click", "**" );
$anchor2.on( "click", function( e ) { // Android 2.3 doesn't support stopImmediatePropagation; jQuery fallbacks to stopPropagation
e.stopImmediatePropagation(); // in such a case.
ok( true, "anchor was clicked and prop stopped" ); // Support: Android 2.3
}); if ( !/android 2\.3/i.test( navigator.userAgent ) ) {
$anchor2[0].addEventListener( "click", neverCallMe, false ); $anchor2.on( "click", function( e ) {
fakeClick( $anchor2 ); e.stopImmediatePropagation();
$anchor2[0].removeEventListener( "click", neverCallMe ); ok( true, "anchor was clicked and prop stopped" );
});
$anchor2[0].addEventListener( "click", neverCallMe, false );
fakeClick( $anchor2 );
$anchor2[0].removeEventListener( "click", neverCallMe );
}
}); });
test("on(), iframes", function() { test("on(), iframes", function() {