[Pkg-javascript-commits] [backbone] 57/281: create empty tail as an invariant

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:01:56 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 6da06836053be7946b8be727bedfc7e102db68d3
Author: Brad Dunbar <dunbarb2 at gmail.com>
Date:   Mon Oct 31 10:36:30 2011 -0400

    create empty tail as an invariant
---
 backbone.js | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/backbone.js b/backbone.js
index 74f2a77..ab2146b 100644
--- a/backbone.js
+++ b/backbone.js
@@ -74,8 +74,10 @@
     bind : function(ev, callback, context) {
       var calls = this._callbacks || (this._callbacks = {});
       var list  = calls[ev] || (calls[ev] = {});
-      var tail = list.tail || list;
-      list.tail = tail.next = {callback: callback, context: context};
+      var tail = list.tail || (list.tail = list.next = {});
+      tail.callback = callback;
+      tail.context = context;
+      list.tail = tail.next = {};
       return this;
     },
 
@@ -83,17 +85,16 @@
     // callbacks for the event. If `ev` is null, removes all bound callbacks
     // for all events.
     unbind : function(ev, callback) {
-      var calls, list, node, prev;
+      var calls, node, prev;
       if (!ev) {
         this._callbacks = {};
       } else if (calls = this._callbacks) {
         if (!callback) {
           calls[ev] = {};
-        } else if (list = node = calls[ev]) {
+        } else if (node = calls[ev]) {
           while (prev = node, node = node.next) {
             if (node.callback !== callback) continue;
             prev.next = node.next;
-            if (list.tail === node) list.tail = prev;
             node.context = node.callback = null;
             break;
           }

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