Do not try to remove drag class if marker as no icon

Since 4c46abe781 it's possible
to have a marker off the map with dragging still enabled.
We want to be able to disable it in this situation too.
This commit is contained in:
Yohan Boniface 2015-02-13 17:53:23 +01:00
parent a998f9b6c8
commit 5b3ba078bf
2 changed files with 10 additions and 2 deletions

View File

@ -41,10 +41,16 @@ describe("Marker", function () {
expect(marker.dragging.enabled()).to.be(true);
map.removeLayer(marker);
map.removeLayer(marker);
map.addLayer(marker);
expect(marker.dragging.enabled()).to.be(true);
map.removeLayer(marker);
// Dragging is still enabled, we should be able to disable it,
// even if marker is off the map.
marker.dragging.disable();
map.addLayer(marker);
});
it("changes the icon to another DivIcon", function () {

View File

@ -30,7 +30,9 @@ L.Handler.MarkerDrag = L.Handler.extend({
dragend: this._onDragEnd
}, this).disable();
L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable');
if (this._marker._icon) {
L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable');
}
},
moved: function () {