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

Commit 8e75674

Browse files
arschmitzGabriel Schulhof
authored andcommitted
loadPage: update to account for if the page is prefetched done update basetag. Fixed #5677 - Navigation: Prefetching pages from other directories offsets <base>-tag
(cherry picked from commit be22887)
1 parent 0a6c2b1 commit 8e75674

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
@@ -729,6 +729,7 @@ define( [
729729
.jqmData( "url", dataUrl );
730730
}
731731

732+
732733
// If we failed to find a page in the DOM, check the URL to see if it
733734
// refers to the first page in the application. If it isn't a reference
734735
// to the first page and refers to non-existent embedded page, error out.
@@ -750,7 +751,7 @@ define( [
750751
return deferred.promise();
751752
}
752753
}
753-
754+
754755
// If the page we are interested in is already in the DOM,
755756
// and the caller did not indicate that we should force a
756757
// reload of the file, we are done. Otherwise, track the
@@ -759,11 +760,14 @@ define( [
759760
if ( !settings.reloadPage ) {
760761
enhancePage( page, settings.role );
761762
deferred.resolve( absUrl, options, page );
763+
//if we are reloading the page make sure we update the base if its not a prefetch
764+
if( base && !options.prefetch ){
765+
base.set(url);
766+
}
762767
return deferred.promise();
763768
}
764769
dupCachedPage = page;
765770
}
766-
767771
var mpc = settings.pageContainer,
768772
pblEvent = new $.Event( "pagebeforeload" ),
769773
triggerData = { url: url, absUrl: absUrl, dataUrl: dataUrl, deferred: deferred, options: settings };
@@ -793,9 +797,9 @@ define( [
793797
$.mobile.hidePageLoadingMsg();
794798
};
795799
}
796-
797800
// Reset base to the default document base.
798-
if ( base ) {
801+
// only reset if we are not prefetching
802+
if ( base && typeof options.prefetch === "undefined" ) {
799803
base.reset();
800804
}
801805

@@ -829,8 +833,8 @@ define( [
829833
RegExp.$1 ) {
830834
url = fileUrl = path.getFilePath( $( "<div>" + RegExp.$1 + "</div>" ).text() );
831835
}
832-
833-
if ( base ) {
836+
//dont update the base tag if we are prefetching
837+
if ( base && typeof options.prefetch === "undefined") {
834838
base.set( fileUrl );
835839
}
836840

@@ -1438,7 +1442,7 @@ define( [
14381442
if ( url && $.inArray( url, urls ) === -1 ) {
14391443
urls.push( url );
14401444

1441-
$.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ) } );
1445+
$.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ),prefetch: true } );
14421446
}
14431447
});
14441448
});

0 commit comments

Comments
 (0)