Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 786ef25

Browse files
committed
Changes to get the navigation unit tests green again.
- Modified changePage() to set isPageTransitioning earlier. - Modified pageSequence() to allow the current changepage callback stack to unwind before firing off the next function in the sequence.
1 parent a2834bb commit 786ef25

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

js/jquery.mobile.navigation.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@
575575
return;
576576
}
577577

578+
// Set the isPageTransitioning flag to prevent any requests from
579+
// entering this method while we are in the midst of loading a page
580+
// or transitioning.
581+
582+
isPageTransitioning = true;
583+
578584
var settings = $.extend( {}, $.mobile.changePage.defaults, options );
579585

580586
// Make sure we have a pageContainer to work with.
@@ -628,11 +634,10 @@
628634
// XXX_jblas: We need to remove this at some point when we allow for transitions
629635
// to the same page.
630636
if( active && active.page[0] === toPage[0] ) {
637+
isPageTransitioning = false;
631638
return;
632639
}
633640

634-
isPageTransitioning = true;
635-
636641
// We need to make sure the page we are given has already been enhanced.
637642
enhancePage( toPage, settings.role );
638643

@@ -708,6 +713,7 @@
708713

709714
releasePageTransitionLock();
710715

716+
711717
// Let listeners know we're all done changing the current page.
712718
mpc.trigger( "changepage" );
713719
});
@@ -924,6 +930,6 @@
924930
else {
925931
$.mobile.changePage( $.mobile.firstPage, { transition: transition, changeHash: false, fromHashChange: true } );
926932
}
927-
});
933+
});
928934

929935
})( jQuery );

tests/jquery.testHelper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@
9292
// bind the recursive call to the event
9393
$.mobile.pageContainer.one(event, function(){
9494
clearTimeout(warnTimer);
95-
self.pageSequence(fns, event);
95+
96+
// Let the current stack unwind before we fire off the next item in the sequence.
97+
setTimeout(function(){ self.pageSequence(fns, event); }, 0);
9698
});
9799

98100
// invoke the function which should, in some fashion,

0 commit comments

Comments
 (0)