[Pkg-javascript-commits] [backbone] 192/281: Fixes #419 -- add a global 'route' event, on Bacckbone.history.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:02:11 UTC 2014


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

js pushed a commit to tag 0.9.0
in repository backbone.

commit 5b43cd9dd1c35b846c9f7c2b63fe3fb359d0b148
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Fri Jan 13 13:47:55 2012 -0500

    Fixes #419 -- add a global 'route' event, on Bacckbone.history.
---
 backbone.js    |  3 ++-
 test/router.js | 16 ++++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/backbone.js b/backbone.js
index 01b5026..3bd4b48 100644
--- a/backbone.js
+++ b/backbone.js
@@ -669,6 +669,7 @@
         var args = this._extractParameters(route, fragment);
         callback && callback.apply(this, args);
         this.trigger.apply(this, ['route:' + name].concat(args));
+        Backbone.history.trigger('route', this, name, args);
       }, this));
     },
 
@@ -728,7 +729,7 @@
   var historyStarted = false;
 
   // Set up all inheritable **Backbone.History** properties and methods.
-  _.extend(Backbone.History.prototype, {
+  _.extend(Backbone.History.prototype, Backbone.Events, {
 
     // The default interval to poll for hash changes, if necessary, is
     // twenty times a second.
diff --git a/test/router.js b/test/router.js
index 02ebf40..17c8105 100644
--- a/test/router.js
+++ b/test/router.js
@@ -59,15 +59,24 @@ $(document).ready(function() {
   Backbone.history.interval = 9;
   Backbone.history.start({pushState: false});
 
+  var lastRoute = null;
+  var lastArgs = [];
+  Backbone.history.bind('route', function(router, route, args) {
+    lastRoute = route;
+    lastArgs = args;
+  });
+
   test("Router: initialize", function() {
     equals(router.testing, 101);
   });
 
-  asyncTest("Router: routes (simple)", 2, function() {
+  asyncTest("Router: routes (simple)", 4, function() {
     window.location.hash = 'search/news';
     setTimeout(function() {
       equals(router.query, 'news');
       equals(router.page, undefined);
+      equals(lastRoute, 'search');
+      equals(lastArgs[0], 'news');
       start();
     }, 10);
   });
@@ -137,11 +146,14 @@ $(document).ready(function() {
     }, 10);
   });
 
-  asyncTest("Router: routes (query)", 2, function() {
+  asyncTest("Router: routes (query)", 5, function() {
     window.location.hash = 'mandel?a=b&c=d';
     setTimeout(function() {
       equals(router.entity, 'mandel');
       equals(router.queryArgs, 'a=b&c=d');
+      equals(lastRoute, 'query');
+      equals(lastArgs[0], 'mandel');
+      equals(lastArgs[1], 'a=b&c=d');
       start();
     }, 10);
   });

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