Skip to content

Commit

Permalink
Pass the polyline's context to the off function so the events will be…
Browse files Browse the repository at this point in the history
… removed in the latest leaflet build
  • Loading branch information
koppelbakje committed Mar 25, 2013
1 parent 0c1e7e5 commit b3aae18
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/draw/handler/Draw.Polyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ L.Draw.Polyline = L.Draw.Feature.extend({
this._map.removeLayer(this._poly);
delete this._poly;

this._mouseMarker.off('click', this._onClick);
this._mouseMarker.off('click', this._onClick, this);
this._map.removeLayer(this._mouseMarker);
delete this._mouseMarker;

// clean up DOM
this._clearGuides();

this._map
.off('mousemove', this._onMouseMove)
.off('zoomend', this._onZoomEnd);
.off('mousemove', this._onMouseMove, this)
.off('zoomend', this._onZoomEnd, this);
},

_finishShape: function () {
Expand Down Expand Up @@ -183,7 +183,7 @@ L.Draw.Polyline = L.Draw.Feature.extend({

// Remove the old marker click handler (as only the last point should close the polyline)
if (this._markers.length > 2) {
this._markers[this._markers.length - 2].off('click', this._finishShape);
this._markers[this._markers.length - 2].off('click', this._finishShape, this);
}
},

Expand Down Expand Up @@ -348,7 +348,7 @@ L.Draw.Polyline = L.Draw.Feature.extend({

_cleanUpShape: function () {
if (this._markers.length > 0) {
this._markers[this._markers.length - 1].off('click', this._finishShape);
this._markers[this._markers.length - 1].off('click', this._finishShape, this);
}
},

Expand Down

0 comments on commit b3aae18

Please sign in to comment.