This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
72 lines
1.3 KiB
JavaScript
72 lines
1.3 KiB
JavaScript
/**
|
|
* @module ol/events/Event
|
|
*/
|
|
|
|
/**
|
|
* @classdesc
|
|
* Stripped down implementation of the W3C DOM Level 2 Event interface.
|
|
* See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.
|
|
*
|
|
* This implementation only provides `type` and `target` properties, and
|
|
* `stopPropagation` and `preventDefault` methods. It is meant as base class
|
|
* for higher level events defined in the library, and works with
|
|
* {@link module:ol/events/Target~Target}.
|
|
*/
|
|
class BaseEvent {
|
|
/**
|
|
* @param {string} type Type.
|
|
*/
|
|
constructor(type) {
|
|
/**
|
|
* @type {boolean}
|
|
*/
|
|
this.propagationStopped;
|
|
|
|
/**
|
|
* The event type.
|
|
* @type {string}
|
|
* @api
|
|
*/
|
|
this.type = type;
|
|
|
|
/**
|
|
* The event target.
|
|
* @type {Object}
|
|
* @api
|
|
*/
|
|
this.target = null;
|
|
}
|
|
|
|
/**
|
|
* Stop event propagation.
|
|
* @api
|
|
*/
|
|
preventDefault() {
|
|
this.propagationStopped = true;
|
|
}
|
|
|
|
/**
|
|
* Stop event propagation.
|
|
* @api
|
|
*/
|
|
stopPropagation() {
|
|
this.propagationStopped = true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {Event|import("./Event.js").default} evt Event
|
|
*/
|
|
export function stopPropagation(evt) {
|
|
evt.stopPropagation();
|
|
}
|
|
|
|
/**
|
|
* @param {Event|import("./Event.js").default} evt Event
|
|
*/
|
|
export function preventDefault(evt) {
|
|
evt.preventDefault();
|
|
}
|
|
|
|
export default BaseEvent;
|