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

Commit

Permalink
Navigation: initialDst no longer needed for resolving funky initial URLs
Browse files Browse the repository at this point in the history
Fixes gh-7177
  • Loading branch information
Gabriel Schulhof committed Aug 16, 2014
1 parent 766a03d commit a4b5aef
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 47 deletions.
5 changes: 0 additions & 5 deletions js/init.js
Expand Up @@ -108,11 +108,6 @@ define([
$.mobile.path.isPath( hash ) ||
hash === $.mobile.dialogHashKey ) ) ) {

// Store the initial destination
if ( $.mobile.path.isHashValid( location.hash ) ) {
$.mobile.navigate.history.initialDst = hash.replace( "#", "" );
}

// make sure to set initial popstate state if it exists
// so that navigation back to the initial page works properly
if ( $.event.special.navigate.isPushStateEnabled() ) {
Expand Down
21 changes: 1 addition & 20 deletions js/widgets/pagecontainer.js
Expand Up @@ -227,18 +227,6 @@ define( [
//
// TODO move check to history object or path object?
to = !$.mobile.path.isPath( to ) ? ( $.mobile.path.makeUrlAbsolute( "#" + to, this._getDocumentBase() ) ) : 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 history entry
// TODO move check to history object?
if ( to === $.mobile.path.makeUrlAbsolute( "#" + history.initialDst, this._getDocumentBase() ) &&
history.stack.length &&
history.stack[0].url !== history.initialDst.replace( $.mobile.dialogHashKey, "" ) ) {
to = this._getInitialContent();
}
}
return to || this._getInitialContent();
},
Expand Down Expand Up @@ -317,8 +305,7 @@ define( [
// key, and the initial destination isn't equal to the current target
// page, use the special dialog handling
if ( history.activeIndex > 0 &&
to.indexOf( $.mobile.dialogHashKey ) > -1 &&
history.initialDst !== to ) {
to.indexOf( $.mobile.dialogHashKey ) > -1 ) {

to = this._handleDialog( changePageOptions, data );

Expand Down Expand Up @@ -1095,12 +1082,6 @@ define( [
} else {
url += "#" + $.mobile.dialogHashKey;
}

// tack on another dialogHashKey if this is the same as the initial hash
// this makes sure that a history entry is created for this dialog
if ( $.mobile.navigate.history.activeIndex === 0 && url === $.mobile.navigate.history.initialDst ) {
url += $.mobile.dialogHashKey;
}
}

// if title element wasn't found, try the page div data attr too
Expand Down
5 changes: 0 additions & 5 deletions js/widgets/popup.js
Expand Up @@ -903,11 +903,6 @@ $.widget( "mobile.popup", {
url = $.mobile.path.parseLocation().hash + hashkey;
}

// Tack on an extra hashkey if this is the first page and we've just reconstructed the initial hash
if ( urlHistory.activeIndex === 0 && url === urlHistory.initialDst ) {
url += hashkey;
}

// swallow the the initial navigation event, and bind for the next
this.window.one( "beforenavigate", function( theEvent ) {
theEvent.preventDefault();
Expand Down
17 changes: 0 additions & 17 deletions tests/unit/content/content_core.js
Expand Up @@ -198,23 +198,6 @@
equal( "foo/bar", proto._handleDestination( "#foo/bar" ) );
});

test( "returns initial content when the url is base plus initial destination", function() {
var initialContent = $( "<div>" );

proto._getHistory = function() {
return {
initialDst: "foo",
stack: [ {url: "will not be equal to initial destination"} ]
};
};

proto._getInitialContent = function() {
return initialContent;
};

equal( initialContent, proto._handleDestination(base + "#" + proto._getHistory().initialDst) );
});

module( "Content Widget _recordScroll" );

test( "does not record scroll position when disabled", function() {
Expand Down

0 comments on commit a4b5aef

Please sign in to comment.