Do not fail when closing an interactive tooltip not yet added to the map (#4937)
This commit is contained in:
parent
79d8837b1f
commit
e28f7ae984
@ -287,5 +287,11 @@ describe('Tooltip', function () {
|
|||||||
map.openTooltip('Tooltip', center);
|
map.openTooltip('Tooltip', center);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("can call closeTooltip while not on the map", function () {
|
||||||
|
var layer = new L.Marker(center);
|
||||||
|
layer.bindTooltip('Tooltip', {interactive: true});
|
||||||
|
layer.closeTooltip();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ L.Layer.include({
|
|||||||
closeTooltip: function () {
|
closeTooltip: function () {
|
||||||
if (this._tooltip) {
|
if (this._tooltip) {
|
||||||
this._tooltip._close();
|
this._tooltip._close();
|
||||||
if (this._tooltip.options.interactive) {
|
if (this._tooltip.options.interactive && this._tooltip._container) {
|
||||||
L.DomUtil.removeClass(this._tooltip._container, 'leaflet-clickable');
|
L.DomUtil.removeClass(this._tooltip._container, 'leaflet-clickable');
|
||||||
this.removeInteractiveTarget(this._tooltip._container);
|
this.removeInteractiveTarget(this._tooltip._container);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user