[Pkg-javascript-commits] [backbone] 10/23: Better hash-to-pushState upgrades, via replaceState.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.5.1
in repository backbone.

commit c39ddd0c16ef1c7b372dc37cdc7d283d686e01aa
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Fri Jul 1 17:08:59 2011 -0400

    Better hash-to-pushState upgrades, via replaceState.
---
 backbone.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/backbone.js b/backbone.js
index cce2dcc..5dc7042 100644
--- a/backbone.js
+++ b/backbone.js
@@ -801,16 +801,16 @@
       // opened by a non-pushState browser.
       this.fragment = fragment;
       historyStarted = true;
-      var started = this.loadUrl() || this.loadUrl(window.location.hash);
-      var atRoot  = window.location.pathname == this.options.root;
+      var loc = window.location;
+      var atRoot  = loc.pathname == this.options.root;
       if (this._wantsPushState && !this._hasPushState && !atRoot) {
         this.fragment = this.getFragment(null, true);
         window.location = this.options.root + '#' + this.fragment;
-      } else if (this._wantsPushState && this._hasPushState && atRoot && window.location.hash) {
-        this.navigate(window.location.hash);
-      } else {
-        return started;
+      } else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) {
+        this.fragment = loc.hash.replace(hashStrip, '');
+        window.history.replaceState({}, document.title, loc.protocol + '//' + loc.host + this.options.root + this.fragment);
       }
+      return this.loadUrl();
     },
 
     // Add a route to be tested when the fragment changes. Routes added later may

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list