[Pkg-javascript-commits] [leaflet] 101/301: Add support for layers lacking Events mixin. Fixes #1962

Jonas Smedegaard js at moszumanska.debian.org
Mon Jan 27 22:22:44 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 befc5eb99295aeac7c45832d76f91aa0160882d7
Author: Tom MacWright <tom at macwright.org>
Date:   Tue Sep 17 17:36:05 2013 -0400

    Add support for layers lacking Events mixin. Fixes #1962
---
 spec/suites/layer/FeatureGroupSpec.js | 10 ++++++++++
 src/layer/FeatureGroup.js             |  4 +++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/spec/suites/layer/FeatureGroupSpec.js b/spec/suites/layer/FeatureGroupSpec.js
index fd875e8..f160a1f 100644
--- a/spec/suites/layer/FeatureGroupSpec.js
+++ b/spec/suites/layer/FeatureGroupSpec.js
@@ -47,6 +47,16 @@
 
 			expect(fg.hasLayer(marker)).to.be(true);
 		});
+		it('supports non-evented layers', function () {
+			var fg = L.featureGroup(),
+			    g = L.layerGroup();
+
+			expect(fg.hasLayer(g)).to.be(false);
+
+			fg.addLayer(g);
+
+			expect(fg.hasLayer(g)).to.be(true);
+		});
 	});
 	describe('removeLayer', function () {
 		it('removes the layer passed to it', function () {
diff --git a/src/layer/FeatureGroup.js b/src/layer/FeatureGroup.js
index 83bc117..3e4aaf0 100644
--- a/src/layer/FeatureGroup.js
+++ b/src/layer/FeatureGroup.js
@@ -15,7 +15,9 @@ L.FeatureGroup = L.LayerGroup.extend({
 			return this;
 		}
 
-		layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);
+		if ('on' in layer) {
+			layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);
+		}
 
 		L.LayerGroup.prototype.addLayer.call(this, layer);
 

-- 
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