diff --git a/js/events/touch.js b/js/events/touch.js index 37458e9e457..dfa2e0cc81f 100644 --- a/js/events/touch.js +++ b/js/events/touch.js @@ -313,8 +313,8 @@ define( [ "jquery", "../vmouse", "../support/touch" ], function( jQuery ) { $.each({ scrollstop: "scrollstart", taphold: "tap", - swipeleft: "swipe", - swiperight: "swipe" + swipeleft: "swipe.left", + swiperight: "swipe.right" }, function( event, sourceEvent ) { $.event.special[ event ] = { diff --git a/tests/integration/swipe/binding-tests.html b/tests/integration/swipe/binding-tests.html new file mode 100644 index 00000000000..81420e5c751 --- /dev/null +++ b/tests/integration/swipe/binding-tests.html @@ -0,0 +1,39 @@ + + + + + + jQuery Mobile Swipe Event Test Suite + + + + + + + + + + + + + + + + +
+ +
+
+
+ + diff --git a/tests/integration/swipe/binding_tests_core.js b/tests/integration/swipe/binding_tests_core.js new file mode 100644 index 00000000000..2cad6a5ef3a --- /dev/null +++ b/tests/integration/swipe/binding_tests_core.js @@ -0,0 +1,39 @@ +test( "Unbinding swipeleft leaves swiperight handler alone", function() { + var dummy = function() {}, + swipeLength = function() { + var swipe = $._data( document, "events" ).swipe; + + return swipe ? swipe.length : 0; + }, + initialSwipeLength = swipeLength(); + + $( document ).on( "swipeleft swiperight", ".ui-page", dummy ); + + deepEqual( swipeLength(), initialSwipeLength + 2, + "Two swipe handlers are present after attaching swipeleft and swiperight" ); + + $( document ).off( "swipeleft", ".ui-page", dummy ); + + deepEqual( swipeLength(), initialSwipeLength + 1, + "One swipe handler is present after detaching swipeleft" ); + + $( document ).on( "swipeleft", ".ui-page", dummy ); + + deepEqual( swipeLength(), initialSwipeLength + 2, + "Two swipe handlers are present after reattaching swipeleft" ); + + $( document ).off( "swiperight", ".ui-page", dummy ); + + deepEqual( swipeLength(), initialSwipeLength + 1, + "One swipe handler is present after detaching swiperight" ); + + $( document ).on( "swiperight", ".ui-page", dummy ); + + deepEqual( swipeLength(), initialSwipeLength + 2, + "Two swipe handlers are present after reattaching swiperight" ); + + $( document ).off( "swipeleft swiperight", ".ui-page", dummy ); + + deepEqual( swipeLength(), initialSwipeLength, + "No swipe handlers are present after detaching both swipeleft and swiperight" ); +});