[Pkg-javascript-commits] [backbone] 11/23: issue #451 + test.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:44 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 d2082a54cf428907844a16b37ccb9e5b26a414b9
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Fri Jul 1 18:54:49 2011 -0400

    issue #451 + test.
---
 backbone.js    | 16 ++++++++--------
 test/router.js |  6 ++++++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/backbone.js b/backbone.js
index 5dc7042..d059d5f 100644
--- a/backbone.js
+++ b/backbone.js
@@ -847,18 +847,18 @@
     // URL-encoding the fragment in advance. This does not trigger
     // a `hashchange` event.
     navigate : function(fragment, triggerRoute) {
-      fragment = (fragment || '').replace(hashStrip, '');
-      if (this.fragment == fragment || this.fragment == decodeURIComponent(fragment)) return;
+      var frag = (fragment || '').replace(hashStrip, '');
+      if (this.fragment == frag || this.fragment == decodeURIComponent(frag)) return;
       if (this._hasPushState) {
         var loc = window.location;
-        if (fragment.indexOf(this.options.root) != 0) fragment = this.options.root + fragment;
-        this.fragment = fragment;
-        window.history.pushState({}, document.title, loc.protocol + '//' + loc.host + fragment);
+        if (frag.indexOf(this.options.root) != 0) frag = this.options.root + frag;
+        this.fragment = frag;
+        window.history.pushState({}, document.title, loc.protocol + '//' + loc.host + frag);
       } else {
-        window.location.hash = this.fragment = fragment;
-        if (this.iframe && (fragment != this.getFragment(this.iframe.location.hash))) {
+        window.location.hash = this.fragment = frag;
+        if (this.iframe && (frag != this.getFragment(this.iframe.location.hash))) {
           this.iframe.document.open().close();
-          this.iframe.location.hash = fragment;
+          this.iframe.location.hash = frag;
         }
       }
       if (triggerRoute) this.loadUrl(fragment);
diff --git a/test/router.js b/test/router.js
index 170daa7..2186ba3 100644
--- a/test/router.js
+++ b/test/router.js
@@ -71,6 +71,12 @@ $(document).ready(function() {
     }, 10);
   });
 
+  test("Router: routes via navigate", 2, function() {
+    Backbone.history.navigate('search/manhattan/p20', true);
+    equals(router.query, 'manhattan');
+    equals(router.page, '20');
+  });
+
   asyncTest("Router: routes (splats)", function() {
     window.location.hash = 'splat/long-list/of/splatted_99args/end';
     setTimeout(function() {

-- 
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