Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/events/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] = {
Expand Down
39 changes: 39 additions & 0 deletions tests/integration/swipe/binding-tests.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile Swipe Event Test Suite</title>

<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/requirejs.config.js"></script>
<script src="../../../js/jquery.tag.inserter.js"></script>
<script src="../../jquery.setNameSpace.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>

<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
<link rel="stylesheet" href="../../jqm-tests.css"/>
<script src="../../../external/qunit/qunit.js"></script>

<script>
$.testHelper.asyncLoad([
[
"events/touch"
],
[ "init" ],
[
"binding_tests_core.js"
]
]);
</script>
<script src="../../swarminject.js"></script>
</head>
<body>
<div id="qunit"></div>

<div data-nstest-role="page" id="start-page">
<div class="ui-content" id="page-content"></div>
</div>
</body>
</html>
39 changes: 39 additions & 0 deletions tests/integration/swipe/binding_tests_core.js
Original file line number Diff line number Diff line change
@@ -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" );
});