]> source.dussan.org Git - jquery.git/commitdiff
Event: Don't test stopImmediatePropagation in Android 2.3
authorMichał Gołębiowski <m.goleb@gmail.com>
Tue, 18 Mar 2014 19:55:50 +0000 (20:55 +0100)
committerMichał Gołębiowski <m.goleb@gmail.com>
Tue, 18 Mar 2014 19:55:50 +0000 (20:55 +0100)
Android 2.3 doesn't support stopImmediatePropagation; jQuery fallbacks
to stopPropagation in such a case.

test/unit/event.js

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