aboutsummaryrefslogtreecommitdiffstats
path: root/test/jqLiteSpec.js
diff options
context:
space:
mode:
authorChris Chua2013-11-24 14:40:46 -0800
committerVojta Jina2013-12-16 16:39:13 -0800
commit2f91cfd0d2986899c38641100c1851b2f9d3888a (patch)
tree944561843e11e07bfd0d2986c5560539eabde3e0 /test/jqLiteSpec.js
parentd5c5e2b5848dcb312390549a92c94c76822a5f4f (diff)
downloadangular.js-2f91cfd0d2986899c38641100c1851b2f9d3888a.tar.bz2
fix(jqLite): support unbind self within handler
If an event handler unbinds itself, the next event handler on the same event and element doesn't get executed. This works fine in jQuery, and since jqLite doesn't support .one, this might be a common use case.
Diffstat (limited to 'test/jqLiteSpec.js')
-rw-r--r--test/jqLiteSpec.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index c4f47dcd..3a8fd404 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -1120,6 +1120,26 @@ describe('jqLite', function() {
});
+ it('should deregister specific listener within the listener and call subsequent listeners', function() {
+ var aElem = jqLite(a),
+ clickSpy = jasmine.createSpy('click'),
+ clickOnceSpy = jasmine.createSpy('clickOnce').andCallFake(function() {
+ aElem.off('click', clickOnceSpy);
+ });
+
+ aElem.on('click', clickOnceSpy);
+ aElem.on('click', clickSpy);
+
+ browserTrigger(a, 'click');
+ expect(clickOnceSpy).toHaveBeenCalledOnce();
+ expect(clickSpy).toHaveBeenCalledOnce();
+
+ browserTrigger(a, 'click');
+ expect(clickOnceSpy).toHaveBeenCalledOnce();
+ expect(clickSpy.callCount).toBe(2);
+ });
+
+
it('should deregister specific listener for multiple types separated by spaces', function() {
var aElem = jqLite(a),
masterSpy = jasmine.createSpy('master'),