[Pkg-javascript-commits] [leaflet-markercluster] 414/479: Test and fix for removing and re-adding a marker while we are not on the map.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:01:02 UTC 2014


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

js pushed a commit to branch master
in repository leaflet-markercluster.

commit 31a8bb777298717803c4cc4444350626878ebdda
Author: danzel <danzel at localhost.geek.nz>
Date:   Thu Jul 18 11:24:13 2013 +1200

    Test and fix for removing and re-adding a marker while we are not on the map.
---
 spec/suites/onAddSpec.js  | 18 ++++++++++++++++++
 src/MarkerClusterGroup.js |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/spec/suites/onAddSpec.js b/spec/suites/onAddSpec.js
index c0e8493..336e45a 100644
--- a/spec/suites/onAddSpec.js
+++ b/spec/suites/onAddSpec.js
@@ -34,4 +34,22 @@
 
 		expect(ex).to.not.be(null);
 	});
+
+	it('successfully handles removing and re-adding a layer while not on the map', function () {
+		map.options.maxZoom = 18;
+		var group = new L.MarkerClusterGroup();
+		var marker = new L.Marker([1.5, 1.5]);
+
+		map.addLayer(group);
+		group.addLayer(marker);
+
+		map.removeLayer(group);
+		group.removeLayer(marker);
+		group.addLayer(marker);
+
+		map.addLayer(group);
+
+		expect(map.hasLayer(group)).to.be(true);
+		expect(group.hasLayer(marker)).to.be(true);
+	});
 });
\ No newline at end of file
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 5a5426d..89b26e7 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -383,7 +383,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 		for (i = 0, l = this._needsRemoving.length; i < l; i++) {
 			layer = this._needsRemoving[i];
-			this._removeLayer(layer);
+			this._removeLayer(layer, true);
 		}
 		this._needsRemoving = [];
 

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



More information about the Pkg-javascript-commits mailing list