[Pkg-javascript-commits] [leaflet] 175/301: Fix a potential event bug due to bad cleanup.

Jonas Smedegaard js at moszumanska.debian.org
Mon Jan 27 22:22:49 UTC 2014


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

js pushed a commit to branch master
in repository leaflet.

commit 579c044c0086d924fd0ed3d3dc4ee0f16ed062cc
Author: danzel <danzel at localhost.geek.nz>
Date:   Tue Nov 5 10:21:32 2013 +1300

    Fix a potential event bug due to bad cleanup.
---
 spec/suites/core/EventsSpec.js | 21 +++++++++++++++++++++
 src/core/Events.js             |  1 +
 2 files changed, 22 insertions(+)

diff --git a/spec/suites/core/EventsSpec.js b/spec/suites/core/EventsSpec.js
index b16429d..ff2058f 100644
--- a/spec/suites/core/EventsSpec.js
+++ b/spec/suites/core/EventsSpec.js
@@ -230,6 +230,27 @@ describe('Events', function() {
 			expect(spy.called).to.be(false);
 		});
 
+		it('correctly removes all listeners if given no fn', function () {
+			var obj = new Klass(),
+			    spy = sinon.spy(),
+			    foo = {},
+			    foo2 = {},
+			    foo3 = {};
+
+			obj.addEventListener('test', spy, foo2);
+			obj.addEventListener('test', spy, foo3);
+
+			obj.removeEventListener('test'); // Removes both of the above listeners
+
+			expect(obj.hasEventListeners('test')).to.be(false);
+
+			//Add and remove a listener
+			obj.addEventListener('test', spy, foo2);
+			obj.removeEventListener('test', spy, foo2);
+			
+			expect(obj.hasEventListeners('test')).to.be(false);
+		});
+
 		it('makes sure an event is not triggered if a listener is removed during dispatch',function() {
 			var obj = new Klass(),
 			    spy = sinon.spy();
diff --git a/src/core/Events.js b/src/core/Events.js
index 37de67e..338a340 100644
--- a/src/core/Events.js
+++ b/src/core/Events.js
@@ -90,6 +90,7 @@ L.Mixin.Events = {
 				// clear all listeners for a type if function isn't specified
 				delete events[type];
 				delete events[indexKey];
+				delete events[indexLenKey];
 
 			} else {
 				listeners = context && typeIndex ? typeIndex[contextId] : events[type];

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet.git



More information about the Pkg-javascript-commits mailing list