Skip to content
This repository
Browse code

[navigation] Handle the case where the initial URL contains a non-pat…

…h hash that points to a non-existing page
  • Loading branch information...
commit 207f854733ebdd684e2f7fea44201621cd91bc08 1 parent 67b9ac1
Gabriel "_|Nix|_" Schulhof authored
5  js/jquery.mobile.init.js
@@ -85,6 +85,11 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
85 85
 				$.mobile.path.isHashValid( location.hash ) &&
86 86
 				( $( location.hash + ':jqmData(role="page")' ).length ||
87 87
 					$.mobile.path.isPath( location.hash ) ) ) ) {
  88
+
  89
+				// Store the initial destination
  90
+				if ( $.mobile.path.isHashValid( location.hash ) ) {
  91
+					$.mobile.urlHistory.initialDst = $.mobile.path.parseUrl( location.href ).hash.replace( "#", "" );
  92
+				}
88 93
 				$.mobile.changePage( $.mobile.firstPage, { transition: "none", reverse: true, changeHash: false, fromHashChange: true } );
89 94
 			}
90 95
 			// otherwise, trigger a hashchange to load a deeplink
8  js/jquery.mobile.navigation.js
@@ -1481,6 +1481,14 @@ define( [
1481 1481
 				// since the hashchange could've been the result of a forward/backward navigation
1482 1482
 				// that crosses from an external page/dialog to an internal page/dialog.
1483 1483
 				to = ( typeof to === "string" && !path.isPath( to ) ) ? ( path.makeUrlAbsolute( '#' + to, documentBase ) ) : to;
  1484
+
  1485
+				// If we're about to go to an initial URL that contains a reference to a non-existent
  1486
+				// internal page, go to the first page instead. We know that the initial hash refers to a
  1487
+				// non-existent page, because the initial hash did not end up in the initial urlHistory entry
  1488
+				if ( to === path.makeUrlAbsolute( '#' + urlHistory.initialDst, documentBase ) &&
  1489
+					urlHistory.stack.length && urlHistory.stack[0].url !== urlHistory.initialDst.replace( dialogHashKey, "" ) ) {
  1490
+					to = $.mobile.firstPage;
  1491
+				}
1484 1492
 				$.mobile.changePage( to, changePageOptions );
1485 1493
 			}	else {
1486 1494
 				//there's no hash, go to the first page in the dom

1 note on commit 207f854

Jeroen van Warmerdam

I don't understand why this was added...
It is causing issues described in this issue #5121

Please sign in to comment.
Something went wrong with that request. Please try again.