diff --git a/spec/suites/layer/PopupSpec.js b/spec/suites/layer/PopupSpec.js index 6d6704803..e662469a9 100644 --- a/spec/suites/layer/PopupSpec.js +++ b/spec/suites/layer/PopupSpec.js @@ -308,6 +308,21 @@ describe('Popup', () => { expect(map.hasLayer(layer._popup)).to.be.true; }); + + it('can change popup content with a click on removed DOM', () => { + const popup = new Popup() + .setLatLng(center) + .setContent('

initial

') + .openOn(map); + + + UIEventSimulator.fire('click', popup._container.querySelector('p')); + + expect(popup._container.innerHTML).to.not.contain('initial'); + expect(popup._container.innerHTML).to.contain('changed'); + expect(map.hasLayer(popup)).to.be.true; + }); + describe('autoPan option should pan popup into visibility', () => { // Helper function which calculates the offset of the map-container & popup-container in pixel function getPopupOffset(map, popup) { diff --git a/src/map/Map.js b/src/map/Map.js index 70527d810..a45938cc4 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -1389,7 +1389,7 @@ export const Map = Evented.extend({ _isClickDisabled(el) { while (el && el !== this._container) { - if (el['_leaflet_disable_click']) { return true; } + if (el['_leaflet_disable_click'] || !el.parentNode) { return true; } el = el.parentNode; } },