Simplify event handling for custom elements

This commit is contained in:
Andreas Hocevar
2021-03-03 15:00:25 +01:00
parent c9ec2083d3
commit 83ee87581f
4 changed files with 38 additions and 26 deletions

View File

@@ -7,7 +7,7 @@ import MapEvent from './MapEvent.js';
* @classdesc
* Events emitted as map browser events are instances of this type.
* See {@link module:ol/PluggableMap~PluggableMap} for which events trigger a map browser event.
* @template {UIEvent} EVENT
* @template {UIEvent|import("./MapBrowserEventHandler").PointerEventData} EVENT
*/
class MapBrowserEvent extends MapEvent {
/**
@@ -88,7 +88,9 @@ class MapBrowserEvent extends MapEvent {
*/
preventDefault() {
super.preventDefault();
this.originalEvent.preventDefault();
if ('preventDefault' in this.originalEvent) {
/** @type {UIEvent} */ (this.originalEvent).preventDefault();
}
}
/**
@@ -98,7 +100,9 @@ class MapBrowserEvent extends MapEvent {
*/
stopPropagation() {
super.stopPropagation();
this.originalEvent.stopPropagation();
if ('stopPropagation' in this.originalEvent) {
/** @type {UIEvent} */ (this.originalEvent).stopPropagation();
}
}
}