Skip to content

Commit be22887

Browse files
committed
loadPage: update to account for if the page is prefetched done update basetag. Fixed jquery-archive#5677 - Navigation: Prefetching pages from other directories offsets <base>-tag
1 parent 9344ddf commit be22887

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

js/jquery.mobile.navigation.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ define( [
430430
.jqmData( "url", dataUrl );
431431
}
432432

433+
433434
// If we failed to find a page in the DOM, check the URL to see if it
434435
// refers to the first page in the application. If it isn't a reference
435436
// to the first page and refers to non-existent embedded page, error out.
@@ -451,7 +452,7 @@ define( [
451452
return deferred.promise();
452453
}
453454
}
454-
455+
455456
// If the page we are interested in is already in the DOM,
456457
// and the caller did not indicate that we should force a
457458
// reload of the file, we are done. Otherwise, track the
@@ -460,11 +461,14 @@ define( [
460461
if ( !settings.reloadPage ) {
461462
enhancePage( page, settings.role );
462463
deferred.resolve( absUrl, options, page );
464+
//if we are reloading the page make sure we update the base if its not a prefetch
465+
if( base && !options.prefetch ){
466+
base.set(url);
467+
}
463468
return deferred.promise();
464469
}
465470
dupCachedPage = page;
466471
}
467-
468472
var mpc = settings.pageContainer,
469473
pblEvent = new $.Event( "pagebeforeload" ),
470474
triggerData = { url: url, absUrl: absUrl, dataUrl: dataUrl, deferred: deferred, options: settings };
@@ -494,9 +498,9 @@ define( [
494498
$.mobile.hidePageLoadingMsg();
495499
};
496500
}
497-
498501
// Reset base to the default document base.
499-
if ( base ) {
502+
// only reset if we are not prefetching
503+
if ( base && typeof options.prefetch === "undefined" ) {
500504
base.reset();
501505
}
502506

@@ -530,8 +534,8 @@ define( [
530534
RegExp.$1 ) {
531535
url = fileUrl = path.getFilePath( $( "<div>" + RegExp.$1 + "</div>" ).text() );
532536
}
533-
534-
if ( base ) {
537+
//dont update the base tag if we are prefetching
538+
if ( base && typeof options.prefetch === "undefined") {
535539
base.set( fileUrl );
536540
}
537541

@@ -1251,7 +1255,7 @@ define( [
12511255
if ( url && $.inArray( url, urls ) === -1 ) {
12521256
urls.push( url );
12531257

1254-
$.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ) } );
1258+
$.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ),prefetch: true } );
12551259
}
12561260
});
12571261
});

0 commit comments

Comments
 (0)