Merge pull request #2032 from Leaflet/featuregroup-check
Add support for layers lacking Events mixin. Fixes #1962
This commit is contained in:
commit
74a5b4dba7
@ -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 () {
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user