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

Commit 70f0c95

Browse files
committed
Corrected first pass at query params to embedded pages
1 parent ff79b5f commit 70f0c95

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

js/jquery.mobile.init.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
4646
// find present pages
4747
var path = $.mobile.path,
4848
$pages = $( ":jqmData(role='page'), :jqmData(role='dialog')" ),
49-
hash = path.convertUrlToDataUrl( path.parseLocation().hash ),
50-
hashPage = document.getElementById( hash );
49+
hash = path.stripHash( path.stripQueryParams(path.parseLocation().hash) ),
50+
hashPage = document.getElementById( hash );
5151

5252
// if no pages are found, create one with body's inner html
5353
if ( !$pages.length ) {
@@ -94,10 +94,15 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
9494
if ( $.mobile.path.isHashValid( location.hash ) ) {
9595
$.mobile.urlHistory.initialDst = hash.replace( "#", "" );
9696
}
97-
$.mobile.changePage( $.mobile.firstPage, { transition: "none", reverse: true, changeHash: false, fromHashChange: true } );
98-
}
99-
// otherwise, trigger a hashchange to load a deeplink
100-
else {
97+
98+
$.mobile.changePage( $.mobile.firstPage, {
99+
transition: "none",
100+
reverse: true,
101+
changeHash: false,
102+
fromHashChange: true
103+
});
104+
} else {
105+
// otherwise, trigger a hashchange to load a deeplink
101106
$window.trigger( "hashchange", [ true ] );
102107
}
103108
}

js/jquery.mobile.navigation.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ define( [
235235
return url.replace( /^#/, "" );
236236
},
237237

238+
stripQueryParams: function( url ) {
239+
return url.replace( /\?.*$/, "" );
240+
},
241+
238242
//remove the preceding hash, any query params, and dialog notations
239243
cleanHash: function( hash ) {
240244
return path.stripHash( hash.replace( /\?.*$/, "" ).replace( dialogHashKey, "" ) );

tests/jquery.testHelper.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,19 +378,24 @@
378378

379379
stop();
380380

381-
timeout = setTimeout( start, 2000);
381+
timeout = setTimeout( function() {
382+
start();
383+
throw "navigation reset timed out";
384+
}, 5000);
382385

383386
$(document).one( "pagechange", function() {
384387
clearTimeout( timeout );
385388
start();
386389
});
387390

388-
location.hash = hash ? "#" + hash : "";
391+
392+
hash = location.hash.replace( "#", "" ) !== url ? url : "";
393+
location.hash = hash;
389394
};
390395

391396
// force the page reset for hash based tests
392397
if ( location.hash && !$.support.pushState ) {
393-
pageReset();
398+
pageReset( url );
394399
}
395400

396401
// force the page reset for all pushstate tests

tests/unit/navigation/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
<link rel="stylesheet" href="../../../external/qunit.css"/>
1717
<script src="../../../external/qunit.js"></script>
1818

19-
<script type="text/javascript" src="navigation_helpers.js"></script>
2019
<script type="text/javascript" src="navigation_core.js"></script>
21-
<script type="text/javascript" src="navigation_paths.js"></script>
2220
<script src="../swarminject.js"></script>
2321
</head>
2422
<body>

tests/unit/navigation/navigation_core.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060

6161
asyncTest( "external page is removed from the DOM after pagehide", function(){
6262
$.testHelper.pageSequence([
63-
navigateTestRoot,
64-
6563
function(){
6664
$.mobile.changePage( "external.html" );
6765
},
@@ -91,7 +89,6 @@
9189
$( document ).bind( "pageremove", removeCallback );
9290

9391
$.testHelper.pageSequence([
94-
navigateTestRoot,
9592

9693
function(){
9794
$.mobile.changePage( "external.html" );
@@ -132,7 +129,6 @@
132129

133130
asyncTest( "external page is cached in the DOM after pagehide", function(){
134131
$.testHelper.pageSequence([
135-
navigateTestRoot,
136132

137133
function(){
138134
$.mobile.changePage( "cached-external.html" );
@@ -154,7 +150,6 @@
154150

155151
asyncTest( "external page is cached in the DOM after pagehide when option is set globally", function(){
156152
$.testHelper.pageSequence([
157-
navigateTestRoot,
158153

159154
function(){
160155
$.mobile.page.prototype.options.domCache = true;

0 commit comments

Comments
 (0)