Permalink
Browse files
Fix #2044 - `once` events are properly removed after triggering
- Loading branch information...
@@ -364,4 +364,13 @@ $(document).ready(function() { | ||
_.extend({}, Backbone.Events).once('event').trigger('event'); | ||
}); | ||
+ test("once removes event after running", 1, function() { | ||
+ var obj = {}; | ||
+ _.extend(obj, Backbone.Events); | ||
+ obj.once('event', function() {}); | ||
+ obj.trigger('event'); | ||
+ console.log(obj._events); | ||
+ equal(obj._events['event'].length, 0, 'once should have removed bound event.'); | ||
+ }); | ||
This comment has been minimized.Show comment Hide comment
braddunbar
Collaborator
|
||
+ | ||
}); |
I agree that the fix above should be added, but I don't think that testing the internals of the implementation is a good strategy. The implementation should be able to change without breaking the tests. Essentially, this fix is an optimization for removing
once
callbacks, not a change in behavior.