Skip to content
Browse files

split out hash monkeying from the navigate method for testing

  • Loading branch information...
1 parent dc37693 commit d8fe5d7e53404b47d77c8904c0543920e95da942 @johnbender johnbender committed
Showing with 16 additions and 8 deletions.
  1. +16 −8 js/navigation/navigator.js
View
24 js/navigation/navigator.js
@@ -45,14 +45,8 @@ define([ "jquery", "./events/navigate", "./path", "./history" ], function( $ ) {
return state;
},
- // TODO reconsider name
- go: function( url, data, noEvents ) {
- var state, href, parsed, loc, hash, popstateEvent,
- isPopStateEvent = $.event.special.navigate.isPushStateEnabled(),
- resolutionUrl = path.isPath( url ) ? path.getLocation() : path.getDocumentUrl();
-
- // Get the url as it would look squashed on to the current resolution url
- href = path.squash( url );
+ hash: function( url, href ) {
+ var parsed, loc, hash;
// Grab the hash for recording. If the passed url is a path
// we used the parsed version of the squashed url to reconstruct,
@@ -73,6 +67,20 @@ define([ "jquery", "./events/navigate", "./path", "./history" ], function( $ ) {
hash = url;
}
+ return hash;
+ },
+
+ // TODO reconsider name
+ go: function( url, data, noEvents ) {
+ var state, href, hash, popstateEvent,
+ isPopStateEvent = $.event.special.navigate.isPushStateEnabled();
+
+ // Get the url as it would look squashed on to the current resolution url
+ href = path.squash( url );
+
+ // sort out what the hash sould be from the url
+ hash = this.hash( url, href );
+
// Here we prevent the next hash change or popstate event from doing any
// history management. In the case of hashchange we don't swallow it
// if there will be no hashchange fired (since that won't reset the value)

0 comments on commit d8fe5d7

Please sign in to comment.
Something went wrong with that request. Please try again.