[Pkg-javascript-commits] [backbone] 214/281: use implicit callback if none provided

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:02:14 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 57ef21839b437d9c9c25fe780f8065e3b209ebbb
Author: Brad Dunbar <dunbarb2 at gmail.com>
Date:   Tue Jan 17 12:12:20 2012 -0500

    use implicit callback if none provided
---
 backbone.js    |  1 +
 test/router.js | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/backbone.js b/backbone.js
index f7d3b8d..bb7333d 100644
--- a/backbone.js
+++ b/backbone.js
@@ -697,6 +697,7 @@
     route : function(route, name, callback) {
       Backbone.history || (Backbone.history = new Backbone.History);
       if (!_.isRegExp(route)) route = this._routeToRegExp(route);
+      if (!callback) callback = this[name];
       Backbone.history.route(route, _.bind(function(fragment) {
         var args = this._extractParameters(route, fragment);
         callback && callback.apply(this, args);
diff --git a/test/router.js b/test/router.js
index 17c8105..4c64a83 100644
--- a/test/router.js
+++ b/test/router.js
@@ -19,12 +19,17 @@ $(document).ready(function() {
 
     initialize : function(options) {
       this.testing = options.testing;
+      this.route('implicit', 'implicit');
     },
 
     counter: function() {
       this.count++;
     },
 
+    implicit: function() {
+      this.count++;
+    },
+
     search : function(query, page) {
       this.query = query;
       this.page = page;
@@ -114,6 +119,12 @@ $(document).ready(function() {
     equals(router.count, 2);
   });
 
+  test("Router: use implicit callback if none provided", function() {
+    router.count = 0;
+    router.navigate('implicit', {trigger: true})
+    equals(router.count, 1);
+  });
+
   asyncTest("Router: routes via navigate with {replace: true}", function() {
     var historyLength = window.history.length;
     router.navigate('search/manhattan/start_here');

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