Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[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
@gabrielschulhof gabrielschulhof authored
Showing with 13 additions and 0 deletions.
  1. +5 −0 js/jquery.mobile.init.js
  2. +8 −0 js/jquery.mobile.navigation.js
View
5 js/jquery.mobile.init.js
@@ -85,6 +85,11 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
$.mobile.path.isHashValid( location.hash ) &&
( $( location.hash + ':jqmData(role="page")' ).length ||
$.mobile.path.isPath( location.hash ) ) ) ) {
+
+ // Store the initial destination
+ if ( $.mobile.path.isHashValid( location.hash ) ) {
+ $.mobile.urlHistory.initialDst = $.mobile.path.parseUrl( location.href ).hash.replace( "#", "" );
+ }
$.mobile.changePage( $.mobile.firstPage, { transition: "none", reverse: true, changeHash: false, fromHashChange: true } );
}
// otherwise, trigger a hashchange to load a deeplink
View
8 js/jquery.mobile.navigation.js
@@ -1481,6 +1481,14 @@ define( [
// since the hashchange could've been the result of a forward/backward navigation
// that crosses from an external page/dialog to an internal page/dialog.
to = ( typeof to === "string" && !path.isPath( to ) ) ? ( path.makeUrlAbsolute( '#' + to, documentBase ) ) : to;
+
+ // If we're about to go to an initial URL that contains a reference to a non-existent
+ // internal page, go to the first page instead. We know that the initial hash refers to a
+ // non-existent page, because the initial hash did not end up in the initial urlHistory entry
+ if ( to === path.makeUrlAbsolute( '#' + urlHistory.initialDst, documentBase ) &&
+ urlHistory.stack.length && urlHistory.stack[0].url !== urlHistory.initialDst.replace( dialogHashKey, "" ) ) {
+ to = $.mobile.firstPage;
+ }
$.mobile.changePage( to, changePageOptions );
} else {
//there's no hash, go to the first page in the dom

1 comment on commit 207f854

@jerone

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.