diff --git a/spec/suites/layer/TooltipSpec.js b/spec/suites/layer/TooltipSpec.js index f32e3fe9..b049d81c 100644 --- a/spec/suites/layer/TooltipSpec.js +++ b/spec/suites/layer/TooltipSpec.js @@ -287,5 +287,11 @@ describe('Tooltip', function () { 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(); + }); + }); diff --git a/src/layer/Layer.Tooltip.js b/src/layer/Layer.Tooltip.js index 50710ad9..09c5a151 100644 --- a/src/layer/Layer.Tooltip.js +++ b/src/layer/Layer.Tooltip.js @@ -121,7 +121,7 @@ L.Layer.include({ closeTooltip: function () { if (this._tooltip) { this._tooltip._close(); - if (this._tooltip.options.interactive) { + if (this._tooltip.options.interactive && this._tooltip._container) { L.DomUtil.removeClass(this._tooltip._container, 'leaflet-clickable'); this.removeInteractiveTarget(this._tooltip._container); }