Merge pull request #10502 from walkermatt/stopevent-removed-target

Stop events that originate with a removed target
This commit is contained in:
Andreas Hocevar
2020-01-17 21:34:39 +01:00
committed by GitHub
6 changed files with 26 additions and 19 deletions

View File

@@ -932,13 +932,15 @@ class PluggableMap extends BaseObject {
// coordinates so interactions cannot be used.
return;
}
let target = /** @type {Node} */ (mapBrowserEvent.originalEvent.target);
const target = /** @type {Node} */ (mapBrowserEvent.originalEvent.target);
if (!mapBrowserEvent.dragging) {
while (target && target !== this.viewport_) {
if (target.parentElement === this.overlayContainerStopEvent_) {
return;
}
target = target.parentElement;
if (this.overlayContainerStopEvent_.contains(target) || !document.body.contains(target)) {
// Abort if the event target is a child of the container that doesn't allow
// event propagation or is no longer in the page. It's possible for the target to no longer
// be in the page if it has been removed in an event listener, this might happen in a Control
// that recreates it's content based on user interaction either manually or via a render
// in something like https://reactjs.org/
return;
}
}
mapBrowserEvent.frameState = this.frameState_;