merged in casey's events optimizations ... tweaking to follow

This commit is contained in:
Jeremy Ashkenas
2012-12-12 12:00:55 -05:00
2 changed files with 100 additions and 103 deletions

View File

@@ -335,7 +335,13 @@ $(document).ready(function() {
obj.trigger('async');
});
test("Off during iteration with once.", 1, function() {
test("once with multiple events.", 2, function() {
var obj = _.extend({}, Backbone.Events);
obj.once('x y', function() { ok(true); });
obj.trigger('x y');
});
test("Off during iteration with once.", 2, function() {
var obj = _.extend({}, Backbone.Events);
var f = function(){ this.off('event', f); };
obj.on('event', f);
@@ -346,10 +352,12 @@ $(document).ready(function() {
obj.trigger('event');
});
test("once with multiple events.", 2, function() {
var obj = _.extend({}, Backbone.Events);
obj.once('x y', function() { ok(true); });
obj.trigger('x y');
test("`once` on `all` should work as expected", 1, function() {
Backbone.once('all', function() {
ok(true);
Backbone.trigger('all');
});
Backbone.trigger('all');
});
});