Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge commit 'upstream/master'
Conflicts:

	js/jquery.mobile.navigation.js
	tests/unit/navigation/index.html
	tests/unit/navigation/navigation_core.js
  • Loading branch information
Oskari Koskimies committed Apr 8, 2011
commit 24b57787d4f6906fa1f72d2a0d69e738a959174b
20 changes: 6 additions & 14 deletions js/jquery.mobile.navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@
}
to.data( "page" )._trigger( "beforeshow", null, { prevPage: from || $("") } );

function loadComplete(){
//console.log("loadComplete:", url);
function pageChangeComplete(){
//console.log("pageChangeComplete:", url);

if (changeHash !== false) {
if (to === $.mobile.firstPage) {
Expand Down Expand Up @@ -870,8 +870,9 @@
//if data-ajax attr is set to false, use the default behavior of a link
hasAjaxDisabled = $this.is( ":jqmData(ajax='false')" ),

//reset our prevDefault value because I'm paranoid.
preventClickDefault = stopClickPropagation = false;
//if the url matches the active page's url
isCurrentPage = path.stripHash(url) == $.mobile.activePage.jqmData("url");

//if there's a data-rel=back attr, go back in history
if( $this.is( ":jqmData(rel='back')" ) ){
window.history.back();
Expand All @@ -880,8 +881,7 @@

//prevent # urls from bubbling
//path.get() is replaced to combat abs url prefixing in IE
//if( url.replace(path.get(), "") == "#" ){
if( href == "#" ){
if( href == "#" || isCurrentPage){
//console.log("Url was:", url);
//for links created purely for interaction - ignore
event.preventDefault();
Expand Down Expand Up @@ -909,14 +909,6 @@

//this may need to be more specific as we use data-rel more
nextPageRole = $this.attr( "data-" + $.mobile.ns + "rel" );
/*
//if it's a relative href, prefix href with base url
if( path.isRelative( url ) && !hadProtocol ){
url = path.makeAbsolute( url );
}

url = path.stripHash( url );
*/
$.mobile.changePage( url, transition, reverse);
event.preventDefault();
});
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/navigation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ <h1>Dialog</h1>
<a href="#/"></a>
</div>

<div data-nstest-role="page" id="self-link">
<a href="#self-link">self!</a>
</div>

</body>
</html>
13 changes: 13 additions & 0 deletions tests/unit/navigation/navigation_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,5 +499,18 @@
same(window.location.hash.replace(/^#/, ""), "", "hash should be empty (not id value)");
start();
}], 1000);

asyncTest( "Page links to the current active page result in the same active page", function(){
$.testHelper.openPage("#self-link");
$.testHelper.sequence([
function(){
$("a[href='#self-link']").click();
},

function(){
same($.mobile.activePage[0], $("#self-link")[0], "self-link page is still the active page" );
start();
}
], 500);
});
})(jQuery);
You are viewing a condensed version of this merge commit. You can view the full changes here.