[Pkg-javascript-commits] [backbone] 147/211: Issue #366, support for namespaced events.

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


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

js pushed a commit to tag 0.5.0
in repository backbone.

commit e8476afef0a0ca979d702b90eb29fbe62b000cbd
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Tue May 24 13:07:11 2011 -0400

    Issue #366, support for namespaced events.
---
 backbone.js  |  2 +-
 test/view.js | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/backbone.js b/backbone.js
index aa11ddf..f769caa 100644
--- a/backbone.js
+++ b/backbone.js
@@ -837,7 +837,7 @@
   };
 
   // Cached regex to split keys for `delegate`.
-  var eventSplitter = /^(\w+)\s*(.*)$/;
+  var eventSplitter = /^(\S+)\s*(.*)$/;
 
   // List of view options to be merged as properties.
   var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName'];
diff --git a/test/view.js b/test/view.js
index 6c74d62..1d52d52 100644
--- a/test/view.js
+++ b/test/view.js
@@ -113,4 +113,25 @@ $(document).ready(function() {
     $("body").trigger("click");
     equals(5, count);
   });
+
+  test("View: custom events, with namespaces", function() {
+    var count = 0;
+    var ViewClass = Backbone.View.extend({
+      el: $('body'),
+      events: {
+        "fake$event.namespaced": "run"
+      },
+      run: function() {
+        count++;
+      }
+    });
+
+    var view = new ViewClass;
+    $('body').trigger('fake$event').trigger('fake$event');
+    equals(count, 2);
+    $('body').unbind('.namespaced');
+    $('body').trigger('fake$event');
+    equals(count, 2);
+  });
+
 });

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