Skip to content

Commit

Permalink
Bugfix: Make sure that marker appearance changes when in editing mode…
Browse files Browse the repository at this point in the history
…. Add regression tests. Fixes part of Leaflet#354 (comment).
  • Loading branch information
justinmanley committed Feb 1, 2015
1 parent ccca4b1 commit e07d284
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 15 additions & 1 deletion spec/suites/EditSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ describe("L.Edit", function () {
marker.editing.enable();
});

it("Is activated correctly when editing.enable() is called.", function () {});
it("Has the leaflet-edit-marker-selected class applied when enabled.", function () {
var editingClass = 'leaflet-edit-marker-selected';

expect(marker.editing.enabled()).to.equal(true);
expect(L.DomUtil.hasClass(marker._icon, editingClass)).to.equal(true);
});

it("Lacks the leaflet-edit-marker-selected class when disabled.", function () {
var editingClass = 'leaflet-edit-marker-selected';

marker.editing.disable();

expect(marker.editing.enabled()).to.equal(false);
expect(L.DomUtil.hasClass(marker._icon, editingClass)).to.equal(false);
});
});

describe("L.Edit.Circle", function () {
Expand Down
6 changes: 3 additions & 3 deletions src/edit/handler/Edit.Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ L.Edit.Marker = L.Handler.extend({
},

_toggleMarkerHighlight: function () {
var icon = this._marker._icon;


// Don't do anything if this layer is a marker but doesn't have an icon. Markers
// should usually have icons. If using Leaflet.draw with Leafler.markercluster there
// is a chance that a marker doesn't.
if (!this._icon) {
if (!icon) {
return;
}

// This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)
var icon = this._icon;

icon.style.display = 'none';

if (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {
Expand Down

0 comments on commit e07d284

Please sign in to comment.